Alternative Syntax
See original GitHub issueHere’s another potential idea @johno: What if MDX had everything inside {{}} be JS, kind of like a reverse of JSX? It’d be a similar concept to Mustache. Here’s an example:
# This is a {{<b>}}*header*{{</b>}}
This is a paragraph.
{{<Button>}}
This is a *Markdown* button
{{</Button>}}
- This is
- a list
{{
// This is just plain JS
const size = 123;
import MyCanvas from './MyCanvas';
}}
{{<MyCanvas width={size} height={size} />}}
Or here’s an idea using just one, which I originally thought would clash with plain text that uses {, but it could be escaped as \{
# This is a {<b>}*header*{</b>}
This is a paragraph.
{<Button>}
This is a *Markdown* button
{</Button>}
- This is
- a list
{
// This is just plain JS
const size = 123;
import MyCanvas from './MyCanvas';
}
{<MyCanvas width={size} height={size} />}
_Originally posted by @sdegutis in https://github.com/mdx-js/mdx/issues/628#issuecomment-519705483_
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:13 (7 by maintainers)
Top Results From Across the Web
php - When, where & why should I use the "alternative syntax ...
I have a few questions regarding this "alternative syntax": When / in what case should I use it? Where / in which part...
Read more >Alternative Syntax - Ruby for Beginners
Strings. First, Ruby has an alternative syntax for defining strings that goes like so: %[any-character]The actual string[the same ...
Read more >Alternative syntax for control structures - PHP - Webdev
PHP offers an alternative syntax for some of its control structures; namely, if, while, for, foreach, and switch. In each case, the basic...
Read more >Alternate PHP Syntax for View Files : CodeIgniter User Guide
Alternate PHP Syntax for View Files. If you do not utilize CodeIgniter's template engine, you'll be using pure PHP in your View files....
Read more >Alternative (square bracket) syntax - Apache FreeMarker Manual
Alternative (square bracket) syntax · While both the "tag syntax" and "interpolation syntax" can be configured to use square brackets, they are ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks everyone for your responses. It seems that, at the moment at least, the requirements I have don’t fully line up with MDX’s roadmap. I think this issue can be considered closed.
Based on the comments I read you basically want:
Which sounds like you want to build a new library, rather than change MDX or even fork it. Which is totally fine, it just doesn’t fit into this project / it’s goals in my opinion.
For reference there was an existing MDX implementation that existed even before we wrote the MDX spec, it didn’t quite suit our needs at the time so we released mdx-js/mdx to solve our particular needs.