Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New lexer for syntax-highlighting #33

Merged
merged 8 commits into from
Nov 18, 2013
Merged

Conversation

stengerh
Copy link
Collaborator

I have experimented with a new lexer which is based on a depth-first, left-to-right traversal of the PegDown AST. The lexer has the following properties:

  • It does not generate empty tokens.
  • The total length of the generated tokens equals the length of the input.
  • It generates an empty token sequence for an empty input.
  • It is able to handle nested styles, e.g. emphasis in headers, bold links, etc. Each peace of Markdown source is hihglighted according to innermost applicable style.

The last one is a change from the current behaviour but could be easily changed if desired by the users. Please see the example below which illustrates the highlighting in the editor.

Markdown source:

### Header with [link][example]
a *b **c** d* e

HTML as rendered by PegDown:

Header with link

a b c d e

Highlighting with old lexer:

## Header with [link][example]
a *b **c** d* e

Highlighting with new lexer:

### Header with [link][example]
a *b **c** d* e

madflow added a commit that referenced this pull request Nov 18, 2013
New lexer for syntax-highlighting
@madflow madflow merged commit 0018e4e into madflow:master Nov 18, 2013
@madflow
Copy link
Owner

madflow commented Nov 18, 2013

Hi,

This is a huge step towards a mature lexer! Thanks for your effort! I only did a quick review - but I will already merge the changes and test if my work lets me ;).

@madflow
Copy link
Owner

madflow commented Nov 20, 2013

@stengerh Until now - the master branch was always also the stable branch. With this merge it is more "experimental". Since we have the tags as releases I do not mind specifically to change this procedure. Do you prefer an extra "experimental" branch?

Also: Some things already work some don't. Should I create issues for my findings?

@stengerh stengerh deleted the lexer-dfs-ltr branch November 20, 2013 10:22
@stengerh
Copy link
Collaborator Author

I agree on the experimental nature of this change. While I have done enough testing to convince myself that the code is reasonably robust, it does change the user experience. I am not sure yet whether we should have an experimental branch. However I would like to have some kind of nightly or preview build to get feedback from the users about new features.

Yes, please create issues if you find anything strange or broken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants