question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Alternative Syntax

See original GitHub issue

Here’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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
sdegutiscommented, Aug 13, 2019

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.

2reactions
timneutkenscommented, Aug 12, 2019

Based on the comments I read you basically want:

  • A different syntax
  • A different parser
  • Different compilation output
  • Different semantics

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found