Giter VIP home page Giter VIP logo

ts-earthli-markup-language's People

Watchers

 avatar  avatar

ts-earthli-markup-language's Issues

Add block tokenizer

  • Enhance tag library to store the following for each tag:
    • Block vs. Inline
    • Preserve newlines
    • Needs end tag
  • Add a list of error tokens to a high-level tag
  • Make the validator that collects errors a high-level tokenizer wrapper around the formatter
  • This level processes tokens from the LowLevelTokenizer in the following way:
    • Define a "default" tag (e.g. paragraph) to indicate how to handle text/newline before the first block tag appears
    • Text: add to stream
    • Newline: check tag properties to determine how to handle:
      • If preserve newlines: add to stream
      • Else if immediately after an open or close tag, discard
      • Else add to stream
    • Tag: collect attributes
      • attribute: add to tag; go to value-expectation mode
      • value: to to attribute-expectation mode
      • error: add to tag or attribute;
      • text or start tag: add current tag to stream, process anew
      • end tag: if expected, add tag to stream, add end tag to stream; else add error
    • EndTag: if expected, add to stream; else add error (out-of-order or no-end-tag-expected)

The formatter can use the following algorithm to process this stream:

For example, for lists:

  • Text: add to current item
  • Newline: store current item; create new item
  • Inline start tag: add to current item
  • Inline end tag: add to current item
  • Block start tag: store current item; create new item
  • Block end tag: store current item

We might be able to make this easier to process by fine-tuning the token output. Not sure it's necessary though. E.g. for HTML paragraphs:

  • Text: Emit <p> if necessary, emit text
  • Newline: emit <p> if necessary; emit </p>
  • Inline start tag: If supported, emit <p> if necessary, emit
  • Inline end tag: If supported, emit (don't have to worry about out-of-order)
  • Block start tag: Emit </p> if necessary
  • Block end tag: We'll never get this, because the other formatter handles it

Add support for truncation

The current text-processor includes support for truncating a text to a certain number of displayable characters. Tag text is not included in the count.

If the caller requests a 10-character truncation of the text <h>This is longer than 10 characters</h>, the the formatter will return <h>This is lo...</h>.

  • For a request to truncate text t to n characters, return at most n characters of non-tag (visible) text
  • Any open tags in the truncated texts should be closed
  • If the text was truncated, then an ellipsis "..." should be included after the text and before any final closing tags

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.