Giter Site home page Giter Site logo

duckdown's People

Contributors

cgiffard avatar danielnitsche avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

avshabanov

duckdown's Issues

! May be too ambiguous to use for emphasis

Consider the following chunk of Duckdown:

"I'm so against this proposal, I don't !even want to hear! from you about it again."

In this circumstance, determining what section of the text is to be emphasised is easy. The first character is directly succeeded by a word character (that is, [a-z0-9]) and could not possibly be an exclamation mark. The second simply terminates the tag.

However, it is not easy to programmatically determine where the emphasis ends in the following:

"I'm so against this proposal, I don't !even want to hear! from you about it again!"

Do we operate on a first match basis? Then what if somebody is trying to use emphasis across a sentence boundary with an exclamation mark?

"Wheelchair manufacturers should !always test their products according to appropriate standards! Safety should be a priority.!"

The intention of the above is that the phrase is emphasised from four words in, right the way through to the end. However, a first-match algorithm would both emphasise incorrectly, terminating the emphasis four words early - as well as swallowing the exclamation point terminating the first sentence and damaging the readability of the phrase.

So what about a greedy algorithm? It suffers from the same problem, just in reverse:

"This fire blanket should !only be used in an emergency!. Folding it back up is annoying and time consuming!"

The intention of the above is to emphasise four words in the middle of the phrase, but the greedy algorithm will erroneously continue all the way to the end of the phrase, again swallowing the final sentence punctuation.


This may occur for a number of different tokens in Duckdown, not just emphasis. Therefore, it's important we start thinking about rules to deal with situational ambiguities. In many cases, specific matching or some context-sensitive smarts is enough to parse properly with the intention of the author intact. But in this case, I think it's too hard.

In my mind, we've got two options.

  1. Change the token to another single character, such as _ which would be less ambiguous. This may crop up in URLs, but parser state can be easily used to switch emphasis off in a safe context-sensitive way.
  2. Duplicate the character to remove ambiguity - i.e. change to !! instead of !.

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.