Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Show HN: Aftertext (breckyunits.com)
96 points by breck on Dec 21, 2021 | hide | past | favorite | 36 comments


This is an interesting idea, though I'd be worried that it could complicate the editing process compared to mixed content and markup. In particular, the examples of selectors in Aftertext rely on the words that are being marked up. This means that if a word or name is going to be changed, then you would have to edit two places in order to make the change correctly rather than just one.


Neat idea, though as I was playing around with it I noticed right away that the following seems to be impossible (or else very non-obvious) via Aftertext:

"How much wood could a woodchuck chuck if a woodchuck could chuck wood?"

I tried

    How much wood could a woodchuck chuck if a woodchuck could chuck wood?
    italics wood
    italics wood
which only seemed to italicize the first "wood", and

    How much wood could a woodchuck chuck if a woodchuck could chuck wood?
    italics wood wood
which obviously failed because it can't find the substring "wood wood". And of course neither of these would match the "wood" in either of the "woodchuck" instances, so no italicization there, either.


It starts getting clunky but I added some new keywords to handle the multiple hits scenarios: match and matchAll. Demo:

https://try.scroll.pub/#scroll%0A%20aftertext%0A%20%20How%20...


  aftertext
  How much wood could a woodchuck chuck if a woodchuck could chuck wood?
  italics [-6:-3,10:13,23:26,43:46]


That looks very inflexible for later edits, marking characters or words means a potentially cumbersome recounting if something is reworded or just if a typo is fixed.

Also, I get the second and subsequent number issue are the three locations to highlight, but what instruction does the first, -6:-3, give to the formatter in your example?


Not a big fan of byte/rune counting. Maybe regex. Maybe more verbosity, like:

  aftertext
    How much wood could a woodchuck chuck if a woodchuck could chuck wood?
    context How much wood
      italics wood
    context could a woodchuck
      italics wood
    context a woodchuck could
      italics wood
    context chuck wood
      italics wood


This is horrific, imagine changing your text and having to update the indices


Nice concept. I wrote a 10 line Javascript to convert HTML to aftertext for no reason.

https://jsfiddle.net/crazyontap/hcL1j2mq/


It's actually extremely old school. ROFF is similar to this

You can just make it .p, .i, .b, etc. .br for line break.

https://www.systutorials.com/docs/linux/man/7-groff_man/


Wouldn’t ROFF require putting the format commands in-line?

Like so:

  How much
  .i wood
  would a
  .i wood
  chuck chuck if a
  .i wood
  chuck could chuck
  .i wood?
I have no experience with ROFF, so please correct me.


The .p, .i etc shorthand makes roff source more readable IMO. The idea of Aftertext is still interesting, though.


Interesting lang.

    aftertext
      It's the difference between helping your Uncle Jack off a horse and helping your uncle jack off a horse.
     italics off
     italics off
Yields (in your playground)

> It's the difference between helping your Uncle Jack off a horse and helping your uncle jack off a horse.

So it appears I’d have to chain multiple aftertext blocks to highlight both “off”s.


The current implementation just matches the first match, as that was the simplest and most common occurrence. But I have indeed hit this footgun (though it in my case involving my Aunt and a cat), so think will extend soon, probably with an "index" or "matchAll" parameter.


This is really cool. A bit verbose for my taste, but OTOH it could be easier to remember than markdown or html. For example, I often forget the syntax for links in markdown - do the square brackets and parentheses come around the text and link respectively, or is it vice versa?


Someone once told me: "square peg, round hole" as a way to remember this and it stuck ever since.

Hope this helps you too :-)


> forget the syntax for links in markdown - do the square brackets and parentheses come around the text and link

Mnemonic for []() = squared circle

That gives the order.

If you don’t recall text and link, you can also think of [sic] meaning exactly this text, and of links as (optional).


The brackets are the title you want to show and the parentheses are the quiet link behind it.


I see it as calling a function with the link as the Arg stored in some structure. [SomeFunc](CalledWithLinkArg)

Not sure why that one stuck for me.


Here's an interesting benefit this has over inline markup languages: it's natively compatible with text-based CRDTs. Normally, collaborative rich text editing is a strictly harder problem than plain text editing [0]. This is because there is extra structure (e.g., if someone puts a beginning "*" bold in the middle of a sentence, and that sentence is deleted by someone else, then you might end up with an unterminated bold sequence).

But if you swap out inline syntax for per-line syntax, then it seems like plain text CRDT should be enough for collaborative Aftertext editing. Pretty cool

[0] https://www.inkandswitch.com/peritext/


This will be lovely for parallel text: annotating each word with its translation AND retaining the original as well as the annotations in readable form. Even overlapping ranges can be annotated conveniently.

Thank you for this idea!


> but with Aftertext the bytes increase linearly with N, the size of the span you are marking up

Maybe allow regexes for the span?


> regexes

You could do that. I have not needed regex selectors yet but would be easy enough to add if someone had a need.


Or dive into AWK-style selectors all the way:

  aftertext
    The fox jumped the dog
    /^The/ italics
    15,18 italics


Could be good for dictating markup to by voice to an ASR interface like a smart-speaker.


Seems verbose having to repeat everything so often. Given how often I alias stuff after only a few repeats, I can see this becoming annoying quick.

Still always cool to see something new(ish) out there.


Interesting. Seems like there is some overlap with reStructuredText.


The thing I like about markdown and similar syntax's are the simplicity and succinctness. When you take the markup out of context, well you lose context.

My issue with this would be it's verboseness and the extra time it would take to write and understand. I have to read the sentence, then read the first markup and work out which part of the previous sentence it applies to, potentially rereading/scanning the sentence again. This is repeated for each markup.


Very cool, I'm curious have you noticed any productivity improvements after using this to write?


I don't have enough experience with it yet to say. Also, I think improved productivity will be a function of the utility of the markup directives. For example, I just added a new one today ("dateline"), that solves a minor pain point for me. It feels promising, but will have to check back in in 6 months.


sounds good, curious to see what directives are useful


> problem [..] when markup is semantic and not just an augmentation. "*I* did not say that" is different from "I did not say *that*".

I consider this a feature. Domain-specific markup goes e.g.:

  aftertext
    *I* did not say that.
    italics *I*


How do you distinguish between *text that looks like this* and _text that looks like this_?


    aftertext
      Just a guess, but maybe
      bold a guess
      paragraph open
    
    aftertext
      a guess that could work.
      underline a guess
Might render to:

    Just *a guess*, but maybe _a guess_ that could work.


This looks more confusing than Markdown, and harder/messier to edit.


I like this a lot, and I think it's an important contribution!

I think it's a major advantage that the formatting description is provided using words rather than combinations of symbols. Symbols need to be learned, aren't always intuitive (like the markdown link example), and there are only so many combinations of them. Instructions in words can be far more flexible.

I think this a great v1.0, and I look forward to v2.0 and beyond. (I expect that now that this idea has been shared, several people will create spin offs, which is a good thing.)

Some ideas (most of which are no doubt bad but might generate other ideas):

Aftertext to Markdown would be useful and help take advantage of the existing Markdown tool ecosystem.

I wonder if it would be useful to introduce ONE or a very limited set of symbols? For example, perhaps a symbol like ">" or "#" at the beginning of a line to indicate that the following content is formatting instructions for the previous line. But maybe this takes the idea backward.

I wonder if some kinds of formatting could be indicated before rather than after the content, in a way that would be more readable? For example: "heading:". Maybe this is where a symbol or two could be used to differentiate between whether formatting applies to the preceding or following content, or perhaps a colon (:) at the end of the formatting instruction indicates that.

Maybe this could co-exist as an alternative, more expressive syntax within Markdown? For example, for less intuitive constructs like link(this)[that], Aftertext would provide a more intuitive and readable interface even for someone who didn't know Markdown. Maybe Aftertext style isn't needed for things like bold, underline, and italics, because using * or _ or / may be intuitive enough (although Aftertext would be available if it isn't).

Aftertext could also give higher level directives, such as to create links for ALL instances of a particular phrase, or to format the document in a particular way or prefer a type of font if available.

Aftertext could be used to introduce and set the meaning of special symbols that could then be used more conveniently in the document. For example: "*phrase* means bold".

Could Aftertext be made inline with a small number of symbols and result in a net reduction of symbols and greater explicitness and intuitiveness? For example, could an unusual pairing of characters like (! or (: begin an inline Aftertext instruction? Example: (!link to ...). Certain complex Markdown instructions could be removed that way, or alternatives provided, or additional configuration enabled. This could also be configured with: "(!phrase) means inline instructions".


> Could Aftertext be made inline with a small number of symbols and result in a net reduction of symbols and greater explicitness and intuitiveness? For example, could an unusual pairing of characters like (! or (: begin an inline Aftertext instruction? Example: (!link to ...).

I think at that point, you start moving a bit toward Pollen, a Lisp-like fully programmable markup system that's sort of a spiritual relative of troff or TeX aimed specifically at generating HTML. You could absolutely recreate an inline version of aftertext with it.

https://docs.racket-lang.org/pollen/

The aftertext example of

    aftertext
     You write some text. After your text, you add your markup instructions with selectors to select the text to markup, one command per line.
     italics After your text
     italics selectors
Would, in an "aftertext-like Pollen", look like

    You write some text. ◊italics{After your text}, you add your markup instructions with ◊italics{selectors} to select the text to markup, one command per line.
While I find Pollen rather fiddly in practice, it's very powerful.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: