4
If you cannot see this post, you can use this image
Your task is to create a markdown parser that outputs Unicode. It should support , , , and ̲̲̲̲̲̲̲̲̲.
Every alphabetical character should be converted into Math Sans. This includes the characters before an underline character.
Underlines: Add a ̲
character (code point 818) after each character. Underlines can be combined with anything else.
There should be no way to escape a control character.
The following combinations should be supported:
(code point 120224 to 120275 Math Sans)
`
`
(120432 to 120483 Math Monospace)
*
*
(120328 to 120379 Math Sans Italic)
**
**
(120276 to 120327 Math Sans Bold)
***
***
(120380 to 120431 Math Sans Bold Italic)
__
̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲
__
(818 Math Sans with Combining Low Line after each character)
__`
̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲
`__
(Math Sans Monospace with Combining Low Line)
Underline should also support Math Sans Italic, Math Sans Bold, and Math Sans Bold Italic
The final output should not contain the characters used to format the text.
Nesting
Some things can be nested. Underlines can nest with any character and can be put in the inside or outside of another control character. Both of these will have an underline
**Underlines __inside the bold__**
__Bold **inside the underline**__
Other things such as bold, monospace, bold italic, and italic can't nest because there are no charactes for it
**This is `not valid` input and will***never be given*
Ambiguous Formatting Characters
Formatting characters that can be ambiguous will never be given. **
is valid because it is bold, but ****
will never be given because it is undefined.
At the end of formatting characters, there will always be another character between the next formatting delimiter of the same character. *format***ing**
will not be given because there should be a character before the next *format* **ing**
delimiter using *
s, however *format*__ing__
could be given because they are different characters used in the delimiter.
**Which is bold ***and which is italic?* <-- Invalid, will never be given
**Oh I see** *now.* <-- Valid
Escaping
Nothing can escape. There is no way to use any of the control characters except for a singular underscore
*There is no way to put a * in the text, not even \* backslashes* <-- All of the asterisks will be italic
Even __newlines
don't interrupt__ formatting <-- newlines don't interrupt will all be underlined
Because the singular _underscore is not a formatting character, it_is allowed_ and will not be removed
Example I/O
Example I
*This* is_a **test** of __the ***markdown*** `parser`__ Multi-line `__should
be__ supported`. Nothing `can\` escape.
Example O
_ ̲̲̲ ̲̲̲̲̲̲̲̲̲ ̲̲̲̲̲̲̲ - ̲̲̲̲̲̲
̲̲̲ . \ .
This input is not valid and it doesn't matter what your program outputs:
*This **is not valid** input* because it nests italic and bold
*Neither `is this`* because it nests italic and monospace
*This***Is not valid** Either because it can be interpreted different ways
As this is code-golf, the shortest solution in bytes wins.
Can you change the title so my eyes stop bleeding? – Christopher – 2018-03-12T18:09:10.427
@Christopher what is wrong with it? https://i.imgur.com/04ErkFu.png
– pfg – 2018-03-12T18:10:13.210@pfg it doesn't format well on some devices. (particularly the underlined characters) – Rɪᴋᴇʀ – 2018-03-12T18:12:54.320
@Riker Hmm, works on my phone https://i.imgur.com/hjBVwHp.png. I've put both in the title for people who can't read it
– pfg – 2018-03-12T18:15:45.807Very related – Shaggy – 2018-03-12T19:13:49.270
@Shaggy but also very different – pfg – 2018-03-12T19:26:30.083
Should we underline whitespace (newlines, spaces)? – Οurous – 2018-03-12T21:43:18.657
@Οurous Yes, underline everything – pfg – 2018-03-12T22:15:30.183
I guess that the input can contains A-Z, a-z, spaces, newline? – user202729 – 2018-03-13T01:19:27.807
@user202729 and all other characters like underscores and stars. If a character isn't azAZ it shouldn't be transformed – pfg – 2018-03-13T01:29:44.757
Can we assume the input contains only printable ASCII? – Erik the Outgolfer – 2018-03-13T10:18:36.440
Also, I think there's an error on the example O, a combining underline should code after the newline too, no? – Erik the Outgolfer – 2018-03-13T11:09:45.430
Yeah I fixed that – pfg – 2018-03-13T18:04:04.030