7 kyu

HTML Generator

1,187 of 2,209jgdodson
Description
Loading description...
Functional Programming
Puzzles
  • Please sign in or sign up to leave a comment.
  • lilsweetcaligula Avatar

    C translation kumited! Please let me know if you would like the random tests to include test cases involving innerHTMLs of nested elements. :)

    • jgdodson Avatar

      The richer the tests, the better. If you don't mind adding them, that'd be great! Also, would you mind editing the kata description by adding a translation of the example code (the code in the description itself) into C? Thanks-a-million!

    • lilsweetcaligula Avatar

      Done! Aside from random tests involving randomly nested elements, I also issued a hotfix (forgot to add the paragraph element to the kata).

      Please let me know if anyone finds any issues or bugs with the translation. I'll fix it.

      Thanks! :)

    • jacobhartzell Avatar

      Hi there. Thanks for the c translaion. I seem to be experiancing some crashes, but only with one of the tests:

      ElementTitleShouldWorkForNestedElements ✔ Test Passed ✘ Test Crashed Exit code: 0 Signal code: 6

      STDERR: *** Error in `/workspace/solution': free(): invalid next size (fast): 0x000000000213ec40 ***

      All the rest of my tests pass, and I'm using the same code for every function call.

  • donaldsebleung Avatar

    A fun Kata to complete but I have a few suggestions:

    1. Maybe add a few random tests if possible (e.g. random strings or random order the methods are called)?
    2. If the HTML Generator constructor accepts no arguments and only has methods anyway, why not just make them class methods so it can be called like this: HTMLGen.div("random string") === "<div>random string</div>"?

    Anyway, good job with the Kata, keep it up :D

  • saiful110816 Avatar

    if any one want to add img tag inside the code .what will have to do. plese show for me

  • saiful110816 Avatar

    can anyone add a 'img' tag

  • computerguy103 Avatar

    Can you please change the tests (Javascript, both preloaded test cases and final test cases) so instead of Test.expect they use Test.assertEquals? It would give much better feedback, showing what your code returned on tests that fail.

    Also note that Test.assertEquals wants the expected value first, then the value being tested:

    Test.assertEquals("expected", htmlGen.p("some text"));
    

    If they're in the other order, the error message will be wrong, saying that the wrong value was expected and the correct value was returned.

  • JoshSchreuder Avatar

    Hi, I've added a CoffeeScript translation, if you want to approve it, instructions for the approval process are here.

  • jolaf Avatar

    In Python translation the pre-set code uses class name HTMLGen, while pre-set tests use class name htmlGen.

    • MMMAAANNN Avatar

      No. htmlGen is not a name of the class, it is an object of class HTMLGen created in the first line of test case code:

      htmlGen = HTMLGen()

      When I was writing Python translation, I copied this behaviour from JS, so this is supposed to be that way.

    • jolaf Avatar

      "class HTMLGen created in the first line of test case code" - that's not true for Python. When I insert a valid solution and press "Run Tests", I get "NameError: name 'htmlGen' is not defined". The pre-set tests look like this exactly, no object defined:

      Test.it("...should generate comments")
      Test.assert_equals(htmlGen.a('test'), 'test')
      
      Test.it("...should generate comments")
      Test.assert_equals(htmlGen.comment('test'), '')
    • MMMAAANNN Avatar

      Oh, now I get what is the problem. I did not create the htmlGen object in the Example test cases (while it is created in test cases intended for submission).

      Unfortunately, I can no longer edit the kata for some reason. Someone with edit access can correct this. Just inserting htmlGen = HTMLGen() in the first line of Example test cases will resolve this issue.

    • jolaf Avatar

      Sorry, I can't edit it neither. :(

    • bkaes Avatar

      Only the author or a moderator can edit the kata at this point, although this seems like a bug.

    • MMMAAANNN Avatar

      This issue seems to be fixed. Can you please re-check?

    • jolaf Avatar

      Yeah, it seems to be fixed. Thank you!

      Issue marked resolved by jolaf 10 years ago
  • MMMAAANNN Avatar

    I created Python translation. Please approve it.

    • jolaf Avatar

      In Python translation the pre-set code uses class name HTMLGen, while pre-set tests use class name htmlGen.

  • ankr Avatar

    Nice kata although I think 7kyu is too low for this one. 6kyu would fit better imo.

  • Clarity Avatar

    I think that since defining methods on prototype is generally a better idea than doing that in the constructor, maybe you'd change the predefined function accordingly?