Coder Social home page Coder Social logo

Razor-style templating about commonmark.net HOT 3 CLOSED

knagis avatar knagis commented on June 30, 2024
Razor-style templating

from commonmark.net.

Comments (3)

Knagis avatar Knagis commented on June 30, 2024

For the inline code elements you would need to add a new parser method in InlineMethods.cs - the current version contains a method InitializeParsers() that will enable you to easily add the mapping and the parser itself is simple enough (since the elements cannot overlap other markdown elements like emphasis can).

For the block code elements you would need to add code to BlockMethods.cs method incorporate_line(). If you apply enough constraints on how the block has to look (for example, always start at the beginning of the line, always end on a separate line) it should not be too hard.

Both parsers will need to add elements into the AST, and you will need a new implementation of the renderer that will output the C# code.

Some other things to consider:

  • Maybe for block elements you could use the markdown fenced code syntax? This way you don't need to extend the block parser at all.
  • The same - maybe for inline code you could use markdown inline code syntax with backticks? With both of these you won't need to modify parsers at all.

Actually if you use the approach of using the default markdown code syntax, you will only need to create a new writer and that can be done without forking the project - just call ProcessStage1/2() and feed the AST object to your own writer.

The drawback is that you loose Razor syntax highlighting. Maybe to mitigate it, you could mix both syntaxes:

```@{
    CommonMarkSettings.UrlResolver = VirtualPathUtility.ToAbsolute;
    var count = Model.Messages.Count();
}
```
Home
----

You have [`@count` unread messages](~/Messages).

from commonmark.net.

Knagis avatar Knagis commented on June 30, 2024

If you need any more information, feel free to reopen the issue.

from commonmark.net.

firelizzard18 avatar firelizzard18 commented on June 30, 2024

Thanks. I'll be working on this again in the future, but it's low priority ATM.

from commonmark.net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.