iainc / Markdown-Content-Blocks

File transclusion syntax for Markdown.
Other
143 stars 7 forks source link

Version: 0.4

John Gruber remarked that image syntax was his biggest mistake with Markdown, and mentioned an alternative:

My best idea for good Markdown img syntax would be to just paste in a URL ending in .jpg/.png/.gif etc.

We liked the idea:

http://example.com/minard.jpg (Napoleon’s disastrous Russian campaign of 1812)
/Flowchart.png "Engineering Flowchart"

At the time, we were also looking for a syntax for file transclusion. The same idea applied equally well to other file types:

/Savings Account.csv 'Recent Transactions'
/Example.swift
/Lorem Ipsum.txt

CSV files are embedded as tables, source code files become code blocks, and embedded text files help writers structure their work:

| Debit | Credit |
|:--|:--|
| 0 | 0 |
[Recent Transactions]

```swift
print("Hello World!")
```

Lorem ipsum dolor sit amet.

We decided to call this syntax “content blocks”. You can try it in iA Writer 4 today.

We think that content blocks are a natural extension of Markdown. We’d be happy if more apps supported them. We’re publishing this spec to aid the process, and to start the conversation around it. We’re just getting started. Your suggestions are welcome.

We describe content block syntax closely following John Gruber’s Markdown Syntax and CommonMark Spec.


A content block consists of:


An online image URL consists of either:

which ends with:

iA Writer automatically uses direct links for images hosted on some services. Currently, it adds raw=1 query item for online image URLs from GitHub and Dropbox.


A local file path consists of one or more path components. Path component consists of:


A content block title consists of either:

Content block titles block titles have obvious uses for some files, for example image alt attributes and figure captions, table captions. Content block titles are ignored when there’s no obvious use, for example with other plain text files.

Source code path extensions are mapped to programming language names with Languages.json when path extensions are different from lowercased programming language names.