Comments (3)
Thinking about it more, it seems I want latex macro-like functionality, but with a semantic focus more than a typographical one. The macro expansion could be handled by any sort of filter, but having a predefined syntax in the spec means anyone writing such a filter would have a simple node in the AST, that is well defined, and standardized, with basic functionality like text replacement covered by the base syntax. I feel like this gives the end user incredible flexibility, which is hard to achieve in any markdown flavor. Additionally, it opens the space up to text-based syntax, that crucially is user-defined, and thus not English first.
from djot.
If you look at my motivating article "Beyond Markdown," you'll see that I envision this kind of extension through four basic constructions that are already in djot:
- verbatim spans with attributes
- verbatim blocks with attributes
- formatted spans with attributes
- formatted blocks with attributes
With these four things and filters, you have quite a lot of flexibility without any additional syntax.
from djot.
@lcnhb What do you want which you can't get with possibly nested spans and divs and filters?
I agree that it would be nice if there were list-like containers so that
[foo][bar][baz]{.quux}
were treated as equivalent to
[[foo]{}[bar]{}[baz]{}]{.quux}
but it is indistinguishable from a reference link followed by a span, so perhaps some separator character like
[foo]+[bar]+[baz]{.quux}
which could be extended to divs too:
{.quux}
:::
foo
+:::
bar
+:::
baz
:::
An actual macro functionality where you can define macros in-text leads to clutter and a lot of (for humans) confusion between what is definitions and what is content, and since I use Pandoc/Markdown in preference to LaTeX to get away from not seeing the text for all the markup I advice strongly against such.
What I do use is my own string templating (pre)processor (which I will put online as soon as I have got some decent documentation written) which takes a hint from lightweight markup languages in preferring punctuation to keywords and is vaguely similar to Bash parameter expansion, e.g.:
-
$(foo)
or$foo
Inserts the value of variable
foo
. -
$<foo bar> $<bæz>
Inserts variable values but variable names are not limited to ASCII alphanumerics, underscores and hyphens.
-
$(foo?|bar)
or$(foo ?| (bar) )
Inserts the value of variable
foo
or if it is empty the string "bar". -
$(foo??bar)
or$( foo ?? (bar) )
Inserts the string "bar" if the variable
foo
is non-empty. -
$(foo?!bar)
or$( foo ?! (bar) )
Inserts the string "bar" if the variable
foo
is empty. -
$( foo ?? $bar ?! (no $game) )
Inserts the value of variable
bar
if variablefoo
is non-empty, or the string "no X", where X is the value of the variablegame
, iffoo
is empty. -
$:foo( $bar, (my $game), 42, (ba@<331>) )
Inserts the return value of calling the function
foo
with four arguments, where@<331>
aka@<0x14b>
is replaced with the Unicode character "ŋ" LATIN SMALL LETTER ENG.
Now the difference between the template processor and a macro processor is of course that with the former variables and functions are defined outside the template file by a script which imports the template engine class and passes the functions to the constructor as a data structure of function references written in the same language as the template engine. Variables are passed as a data structure of strings/numbers/booleans to the template expansion method and/or the constructor. Templates can be passed to the expansion method either as strings or as pre-parsed objects, allowing the calling program to parse a template once and fill it in several times with different data sets.
The templating engine is separate from Pandoc; it can be used for any text to be further processed with any program, but since it is written in pure MoonScript/Lua it can also be used from inside a Pandoc filter, typically defining templates as verbatim spans or blocks, either in the body or the metadata, which after expansion are passed to the Pandoc Lua API's read
function to be converted to AST fragments which are then inserted into the document body. It is still separate from the markup language as parsed by Pandoc; it can be used within Markdown or djot input, and might make sense with other input formats too.
There is a "light" implementation with a subset of the functionality roughly equivalent to what I showed above which is small enough to inline into a Pandoc filter.
from djot.
Related Issues (20)
- Tables with a column of th elements HOT 1
- Typo in syntax.md
- Proposal: Punctuation Character for Code Block's language specifier HOT 6
- Playground: slow on Safari HOT 5
- Supporting “commands” in addition to “classes” in attributes? HOT 2
- Hard-wrapping: require subsequent lines to be indented/quoted? HOT 6
- Two asterisks for “strong”? HOT 3
- Inline footnotes?
- Support `<dfn>`, `<cite>` and `<i>`? HOT 2
- Parsing inconsistency: lazy paragraph lines in lists HOT 4
- The closing delimiter of a div block can interrupt a paragraph HOT 4
- Should block attributes mark a div block delimiter as opening? HOT 1
- section nesting for non-consecutive heading levels HOT 1
- [Proposal] more permissive definition of allowed symbol syntax HOT 43
- [Proposal] Remove leading whitespace HOT 2
- Allow any valid HTML4 identifier string to be a djot identifier string HOT 2
- Allow underscore in task list to denote unchecked item HOT 2
- loose list appears unexpectedly when using tight lists HOT 4
- Use `![alt](path)` syntax not only to include images, but also text files HOT 9
- The definition item in a descrition list is always a paragraph HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from djot.