Handling of tag functions within Pollen Markdown/Authoring mode
#9
Open
opened 5 years ago by kgruschow
·
3 comments
Loading…
Reference in New Issue
There is no content yet.
Delete Branch '%!s(<nil>)'
Deleting a branch is permanent. It CANNOT be undone. Continue?
The "issue" or concern is how default tag function behavior is/is not handled in markdown authoring mode, and it's implications for using pollen.
When in markdown mode (*.poly.pmd),
◊(sidebar "hi!")
renders to:
(p rsquo "(sidebar " ldquo "hi!" rdquo ")")
In pollen markup mode, (*.poly.pm),
◊(sidebar "hi!")
renders to :
(sidebar "hi!")
I can imagine that this is related to the rule that tag functions in markdown authoring mode must render to markdown, however I am curious why the default tag function behavior does not apply. (or what the loss would be in changing it to apply)
In terms of the output X-expressions, if the default tag function behavior applied, then tag functions could be used to make a user extensible version of markdown. (which then using other parts of pollen could be used to have a relatively more readable source render to X-expression then convert to HTML+CSS and LaTeX)
To further the above example, consider the following .pm:
which renders to:
compared to the following markdown:
which renders to:
however, if the default tag function were obeyed even in markdown mode, it might be:
which, at least given my neophyte understanding of X-expressions, would be easier to work with. It would also seem to fulfill the goal of markdown authoring mode, which I presume to be to serve as a gateway drug to fuller use of pollen markup and semantic tags.
As possibly relevant context, I have approval from my supervisor to write a project in "70% markdown with some customization to allow for website and PDF to both look great", but not to use a new markup language. So I would happily ditch markdown entirely, however the difference in readability for everyone else in my (modestly tech savvy government) office threatens to rule out pollen before I get much further.
The source of a
pollen/markdown
file is eventually passed through an actual Markdown parser. Your question seems to boil down to “how can I insert expressions that are exempt from this parsing?” That would require changes to the Markdown parser to be able to parse “things escaped from Markdown” which is not itself a concept inherent in Markdown.So I would recommend seeing if you can lean into the Markdown parser rather than away from it. Meaning, you could adopt a little Markdown notation convention for your sidebar:
Which would become:
And now you can do some further processing (e.g., traverse this X-expression, converting things that are marked as sidebars to actual
(sidebar ···)
expressions)As a side benefit, your project would now be 100% Markdown syntax, and you’ve shifted your customizations into the semantic layer.
I think the current behavior makes the most sense.
If you really want to escape to Pollen in Markdown authoring mode, you can still do so, you just have to define all such tag functions explicitly.
Another trick to take note of…not sure if this helps or not, but HTML is valid within Markdown, and any HTML produced in your Markdown file will get made into "clean" x-expressions:
becomes:
So in Markdown authoring mode it might make sense to think of HTML itself as providing the "default tag" behavior you seek...?
Thanks! Both of those helped considerably. Joel's method works quite well in this context, and nests nicely. (e.g. a section can be in a pollen defined tag but otherwise be conventional markdown). I think I can just doctor up a function to define the list of functions I'll be using.
Matthew's method might work well for a few functions that need to be more "markdown" looking, such as an irritating Q&A section format.