Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Harlowe and auto-closing HTML tags

edited September 2015 in Help! with 2.0
As any rational person, I hate HTML's guts. HTML is great for machines but for people it's a readability killer. That's why people invent stuff as Markdown.

I want to put some HTML inside my passages but keep as much human readability as possible, so I thought that it could be done with variables:
(set: $section to "<div class='section'>")
(set: $sectionend to "</div>") 
$section
This is a section.
$sectionend

But it doesn't work. Why? Because Harlowe decides to auto-close the div in the first variable. So the rendered HTML is more or less like:
<div class='section'></div>
This is a section.

Other thing I tried to do didn't involve variables. I wrote the opening div tag in the header passage and the closing tag in the footer passage, with the goal of enclosing the whole passage (and the final goal of changing the background). The same thing happened: Harlowe added a closing tag right after the opening tag, in the header.

So I wonder why on Earth does Harlowe do this. Is it a byproduct of some other mechanism that makes sure good HTML is produced? Or is it intended to prevent authors from entering bad HTML? In this case, I'd say that authors who can write HTML can be left to clean their own mess.

If there are good solid reasons for this to happen, I'd ask if there's some working trick to create HTML blocks without writing actual HTML (remember, HTML is unreadable and horrible and writing it should always be your last resource). I want to do all kinds of complex CSS stuff but I'd like the text in passages to be as readable as possible.

If nothing is possible apart from writing HTML, I'd ask for a new feature in Harlowe: new markup that is simple and readable and creates generic HTML blocks (for example divs and spans), something like this: &&class is rendered like <div class="class">.

Hope I'm not the only one suffering from terminal HTML hatred.

Comments

  • The problem with your first attempt is that when you do $variable the value of the variable is wrapped in a <tw-expression> tag. Which is why your <div> is being automatically closed.

    Likewise any text in a header is wrapped in a <tw-header>, causing the same problem.

    I agree a (class:) macro would be useful. It'd be a lot cleaner than having lots of <div>s sprinkled through a story.
  • Ah, I see. That's reasonable and I see it can't be changed for this issue.

    So, I would suggest new markup or a macro. Something to generate the two most generic HTML tags (span and div) with a class would be wonderful. Something readable that the eye can easily figure out, unlike HTML.

    Markup (more readable in my opinion):

    ==section==
    To be or not to be...
    ====

    Or a macro:

    (div: section)[
    To be or not to be...
    ]
Sign In or Register to comment.