saibotsivad / blockdown

A Markdown-like syntax that supports defining blocks of text.
https://blockdown.md/
Other
5 stars 0 forks source link

Should have syntax highlighting plugins available #6

Open saibotsivad opened 4 years ago

saibotsivad commented 4 years ago

These are some notes and code samples based on an evening of research.

Since I've never worked with language grammar syntax before, in any meaningful sense, this has been quite an adventure.

I'm using Sublime Text 3, which has its own special syntax, but seems familiar with TextMate, which seems to be a common one.

Here are a slew of links:

One of the bigger problems I ran into was figuring out what scope to put on things.

Following are my notes. As you can see, I did not get very far...

%YAML 1.2
---

file_extensions:
  - md

scope: text.blockdown

variables:
  blockdown_start: '^(---\!)'
  greedy_capture: '.+\]$'
  blockdown_name_end: '(\#|\[|$)'

contexts:
  main:
    - match: |-
          (?x:
            {{blockdown_start}}
            (?i:javascript|js)
            (?:
              {{greedy_capture}}
              | (?:
                (?:[^\[]+\[$)
                (?m:(?:[^\]]+))
                ^\]$
              )
            )
          )
      captures:
        0: meta.code-fence.definition.begin.javascript.blockdown-gfm
        1: punctuation.definition.raw.code-fence.begin.blockdown
        2: constant.other.language-name.blockdown
      embed: scope:source.js
      embed_scope: markup.raw.code-fence.javascript.blockdown-gfm
      escape: '(?:^---\!)'
      escape_captures:
        0: meta.code-fence.definition.end.javascript.blockdown-gfm punctuation.definition.raw.code-fence.end.blockdown

    # - match: |-
    #     (?x:
    #       ^             # at the very start of the line
    #       (---\!)       # the block delimiter starter
    #       ([^\[#]+)     # name: everything up to the first open square bracket or hash
    #       (?:           # id section
    #         (\#)        # the hash is the id delimiter
    #         ([^\[]+)    # everything up to the first open square bracket is the id
    #       )?            # id section is optional
    #       (?:           # single-line metadata
    #         (\[)        # the open square bracket is the start
    #         ([^\]]+)    # everything up to the final close square bracket is the metadata
    #         (\])$       # the last close square bracket is the end of the metadata section
    #       )?            # single-line metadata section is optional
    #     )
    #   captures:
    #     1: markup.raw.block.blockdown
    #     2: variable.fenced.blockdown
    #     3: punctuation.definition.constant.end.blockdown