asciidoctor / atom-language-asciidoc

⚛ AsciiDoc language package for the Atom editor.
https://atom.io/packages/language-asciidoc
MIT License
42 stars 20 forks source link

Refine grammar definition for generic inline/block macro and block title #48

Closed ProgramFan closed 8 years ago

ProgramFan commented 8 years ago

Current language-asciidoc has the following flaws:

  1. generic inline macros like cite:[np] are not properly reconganized.
  2. generic block macros like bibliography::[] are not properly reconganized.
  3. block title with '-' such as '.Real-world applications' are reconganized as '.Real'.

This pull request fixes the above problems by refine the grammar definition regex. It directly enables syntax highlighting support for asciidoctor-bibtex introduced macros, namely cite:[key] and bibliography::[], and fixes block titles with '-' in words.

mojavelinux commented 8 years ago

My understanding is that this change allows short macros (macros with a target) to be matched. Is that a correct assumption? If so, then this change is definitely something we want. It should also allow toc::[] and kbd:[Ctrl,T] to be matched then.

ProgramFan commented 8 years ago

@mojavelinux Exactly.

ProgramFan commented 8 years ago

I have mistakenly created the pull request to merge the master branch, where I also committed some improvements in the snippets, where I changed the header styles and the block deliminaters according to recommanded asciidoc style. If this is not valid for a merge, I can revert these changes.

mojavelinux commented 8 years ago

I would prefer if you did these as two separate pull requests. Not only does it allow us to review the changes individually, you also get credit for both changes in the history (two entries).

ProgramFan commented 8 years ago

I have made a seperate PR for snippts and clear the CI errors. Would you please review it for possible merge? @mojavelinux

mojavelinux commented 8 years ago

I have a minor change request. Once you address that, we can move forward.

ProgramFan commented 8 years ago

Done.

mojavelinux commented 8 years ago

Thank you!

@nicorikken I think this one is ready to go. Can you review? When you merge, please use "squash and merge" so we get this down to one commit.

nicorikken commented 8 years ago

I have merged the current state of this pull-request. I've run some basic tests on the examples given in the documentation and this tread. @ProgramFan can you provide some test-cases which previously failed and with this commit work just fine? In this way the set of tests can be expanded to cover the relevant edge-cases. Either way, thanks for this improvement.

ProgramFan commented 8 years ago

I want to, but how can I add it? in the spec?

nicorikken commented 8 years ago

You can add specs in the file https://github.com/asciidoctor/atom-language-asciidoc/blob/master/spec/asciidoc-spec.coffee They describe an input line and test the expected outcome styles. You can look at the other specs for inspiration. You can run the specs from the command pallet.

nicorikken commented 8 years ago

@ProgramFan I've rebased my PR #46 leaving an improved spec on the block titles. I'd still like some macro tests.