Giter VIP home page Giter VIP logo

Comments (7)

gonzalezreal avatar gonzalezreal commented on May 31, 2024 1

Hi @Kurt57,

That would involve substantial changes in MarkupTokenizer.

  • Refactor the delimiters constant into an array of strings (currently is a CharacterSet)
  • Refactor all the code relying in that constant.

Also it would require changing MarkupToken to accept strings as associated values instead of UnicodeScalar.

Finally, refactor all the code that depends on the MarkupToken (mainly the parser).

As you can see, a lot of work 😅

from markup.

gonzalezreal avatar gonzalezreal commented on May 31, 2024

That depends on what you want to add 😄. Could you please be more specific?

from markup.

saltwat5r avatar saltwat5r commented on May 31, 2024

I.e. add case superscript([MarkupNode]) and many more.

from markup.

gonzalezreal avatar gonzalezreal commented on May 31, 2024

Ok, so you want to add more delimiters. Implementing the superscript would involve the following:

  1. Add the character ^ in MarkupTokenizer
  2. Add a superscript([MarkupNode]) case to MarkupNode
  3. Customize the MarkupNode constructor to handle the ^ delimiter.
  4. Customize the MarkupRenderer to handle superscript nodes appropriately.
  5. Add the corresponding tests here and here.

After completing those steps you should be able to take text like Hello^*world*^ and obtain Helloworld.

from markup.

saltwat5r avatar saltwat5r commented on May 31, 2024

I've done it in the same way, but I was wondering how to do it more flexible without modifying your code and add more cases by i.e. extensions for your classes :)

from markup.

gonzalezreal avatar gonzalezreal commented on May 31, 2024

To be honest, I did not think about a generic way to extend the parser or renderer. Doing so will probably mean not using an enum for the nodes, as swift enums cannot be extended with additional cases. In any case, it is out of the scope and was not my intention when I published this library.

If you find an elegant and generic way to extend it, please do let me know. It is an interesting exercise.

from markup.

Kurt57 avatar Kurt57 commented on May 31, 2024

@gonzalezreal how can I add an rule which looks like "TEXT" where "**" is the new delimiter. The focus on this question is that I use two characters as delimiter.

from markup.

Related Issues (6)

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.