Comments (6)
@Omikhleia As is, calling it a syntax error might be difficult. Verbatim text, is:
Verbatim content begins with a string of consecutive backtick characters (`) and ends with an equal-lengthed string of consecutive backtick characters.
Material between the backticks is treated as verbatim text (backslash escapes don’t work there).
If the content starts or ends with a backtick character, a single space is removed between the opening or closing backticks and the content.
If the text to be parsed as inline ends before a closing backtick string is encountered, the verbatim text extends to the end.
This is verbatim text:
`Verbatim text`
but so is this:
```Verbatim text```
from djot.
Actually, the current djot.js parser does allow ~~~
for code blocks, even though this isn't mentioned in the syntax description. So requiring that is a tempting solution to the ambiguity problem.
On the other hand, using ```
has a pleasing conceptual simplicity; it's not too different from """
for multiline strings and "
for inline strings in some languages.
Curious to hear other comments on this.
from djot.
Actually, the current djot.js parser does allow ~~~ for code blocks, even though this isn't mentioned in the syntax description. So requiring that is a tempting solution to the ambiguity problem.
Yup! It's why I pushed it as an alternative. Glad we're aligned there.
On the other hand, using ``` has a pleasing conceptual simplicity; it's not too different from """ for multiline strings and " > for inline strings in some languages.
It is pretty intuitive at this point to reach for ``` isn't it? I didn't even know about ~~~
as a fence until I glanced at the js implementation to see how it handled the language specifier. Then tried it with github's markdown preview.
Curious to hear other comments on this.
Same. This other issues linked above are already filled with plenty of insights, but I don't think any of them touched on this specific issue/proposal.
from djot.
Ah, one more comment on:
Actually, the current djot.js parser does allow ~~~ for code blocks, even though this isn't mentioned in the syntax description. So requiring that is a tempting solution to the ambiguity problem.
Requiring ~~~
as the code block fence doesn't completely solve the ambiguity issue unless a blank line followed by ~~~
always becomes a code block. But even then, having a specifier character would help because of the ambiguity caused by hard breaks and whether the first word is a language specifier or not.
Without Hard Break
~~~ I'm a paragraph
~~~
leads to
<p>~~~ I’m a paragraph~~~</p>
With Hard Break
While
~~~ I'm
a paragraph
~~~
becomes
<pre><code class="language-I'm">a paragraph
</code></pre>
from djot.
The rule being:
A code block starts with a line of three or more consecutive backticks, optionally followed by a language specifier, but nothing else.
Then
``̀` Some things
``
Should perhaps
- Be a syntax error
- Or a language specifier "Some things"
(Depending on imposing or not restrictions on language specifiers)
from djot.
After writing that last comment, I think I'm slowly pushing myself over towards using tilde instead of backticks.
So, a code block would look like:
~~~
I am not a paragraph and I have no language specifier
~~~
or
~~~ I am not a paragraph and I have a language specifier
~~~
(Everything after ~~~
but before a new line ends up as the language specifier. "I am not a paragraph and I have a language specifier" in this case)
Which has a number of advantages:
- We'd get rid of the ambiguity between paragraphs and code blocks.
- We can't accidentally a paragraph from a code block
- and we don't add new punctuation syntax.
from djot.
Related Issues (20)
- Standalone attributes HOT 6
- Attribute references HOT 4
- Playground should provide examples
- Tables with a column of th elements HOT 1
- Typo in syntax.md
- 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
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.