5 kyu

Basic markdown to HTML

Description
Loading description...
Strings
Regular Expressions
Algorithms
  • Please sign in or sign up to leave a comment.
  • FArekkusu Avatar

    (1) Hashtags are always followed by a space. (2) If you see 7 or more hashtags at the beginning of a string, disregard all hashtags beyond the sixth one.

    Test.assertEquals(format('####### Maecenas...'), '< h6># Maecenas...< /h6>');

    With the current requirements either the input must be "###### # Maecenas..." or the expected result must be "< h6>Maecenas...< /h6>".

  • Voile Avatar

    From random tests:

    ####Ves**tibulum a*nte ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Integer non purus id lac**us sodales interdum. Aliquam **vitae sapien sed mauris tempus sollicitudin in eu lorem. Proin ultrici**es enim*** finibus augue viverra ullamcorper. 
    
    Expected: '< h4>Ves< strong>tibulum a*nte ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Integer non purus id lac< /strong>us sodales interdum. Aliquam < strong>vitae sapien sed mauris tempus sollicitudin in eu lorem. Proin ultrici< /strong>es enim*** finibus augue viverra ullamcorper.< /h4>', 
    instead got: '< p>####Ves< strong>tibulum a*nte ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Integer non purus id lac< /strong>us sodales interdum. Aliquam < strong>vitae sapien sed mauris tempus sollicitudin in eu lorem. Proin ultrici< /strong>es enim*** finibus augue viverra ullamcorper.< /p>'
    

    Leading #s without a space after them are not valid Markdown headers, and should not be considered as a header. Your description and fixed tests expect the extra space to be present too.

    I think your random test generator has missed a whitespace after them.

    • smile67 Avatar

      Should be fixed now, please check;-)!

    • Voile Avatar

      Now there's another issue: tests sometimes generates **** and the test expects < strong>< /strong>.

      Bold items with nothing inside is not valid Markdown, so it shouldn't be parsed that way.

    • Voile Avatar

      Fixed it myself ;-)

      I also improved the descriptions.

      Issue marked resolved by Voile 8 years ago
  • wthit56 Avatar

    I've been trying to complete this kata, but I'm having issues with a randomly generated test:

    Test.assertEquals(format(
      ' * Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Integer non purus id lacus sodales interdum. Aliquam vitae sapien sed mauris tempus ****sollicitudin in eu lorem. Proin ultricies enim finibus augue viverra ulla**mcorper.  '),
      '< li>Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Integer non purus id lacus sodales interdum. Aliquam vitae sapien sed mauris tempus < strong>sollicitudin in eu lorem. Proin ultricies enim finibus augue viverra ulla< /strong>mcorper.< /li>'
    // < li>Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Integer non purus id lacus sodales interdum. Aliquam vitae sapien sed mauris tempus < strong>**sollicitudin in eu lorem. Proin ultricies enim finibus augue viverra ulla< /strong>mcorper.< /li>  
      );
    

    (That last commented out line is what I generated. The test thinks I should be removing extra asterisks after the bolding **. Is that correct?

    • limeyb7 Avatar

      Hey, thanks for the feedback, I'll check it out and get back to you (ignore my last comment if you saw it, made no sense!)

    • limeyb7 Avatar

      Ok, I've made some small changes so that it should now be ok (would be really grateful for any more feedbak!)

      The changes mean that a series of 4 asterisks will return < strong>< /strong> (i.e. empty HTML tags)

      I checked the behaviour against this markdown previewer

    • wthit56 Avatar

      Cool. Seems to be working now. Though I'd make sure there is a specific test for ****-like inputs. Looks like it still may only be generated randomly.

      Issue marked resolved by wthit56 9 years ago
  • wthit56 Avatar

    Is there a reason we need to add spaces within the tags? Seems pretty weird...

    • limeyb7 Avatar

      Yes, there's a reason. In my experience Codewars handles HTML kind of weirdly and the tests don't work as you'd expect, so I added in the extra space in order to escape that. I'll write a note about it in the description of the Kata.