Adding elements

I’m preparing a site for a poet.
I have to add about 100 poems to the site.
Is there a way to add elements automatically?
I can’t imagine adding elements to every line for 100 poems.
Or maybe that’s easy and I can’t see the right path for that problem?

You can use <pre> to retain poem formatting, which includes newlines.

Alternatively, if you’re using something like PHP, you can use nl2br which converts newlines to breaks for you too.

A simple search and replace would go a long-way; really it depends upon how you want to format them and as to whether you want to keep the layouts, etc. I’d basically agree with the reply above.

This is one of the few times when I like Microsoft Word - it has a really good ‘search and replace’ function, where ^p represents a line break.

If you have a poem where you have several verses, separated by a double line break, and you want to enclose each verse in a separate <p> element, what I would do is:

  1. Paste the whole poem into Word.
  2. Search and replace ^p^p with *** (or some other random characters that won’t appear anywhere else)
  3. Search and replace ^p with ^p<br>
  4. Search and replace *** with </p>^p<p> (Use 2 '^p’s there if you prefer a clear line between them in your HTML)
  5. Paste back into your favourite HTML text editor.

Not a bad idea, although the simpler text editors do that too. Beware of encodings, though. I find that stuff from Word mucks up my utf-8 encodings sometmes (haven’t sorted that out yet…)

Personally, though

[B]The Thief[/B]

Forth from his den to steal he stole,
His bags of chink he chunk;
And many a wicked smile he smole,
And many a wink he wunk.

is much easier, as pmw57 mentioned.

While <pre> may be easier, I would still pick <br> first before <pre> when the poem doesn’t require special horizontal layout.

<h2>The Thief</h2>
<p>Forth from his den to steal he stole,<br>
His bags of chink he chunk;<br>
And many a wicked smile he smole,<br>
And many a wink he wunk.</p>

That way you still retain large amounts of semantic meaning.

Ultimately though is 6-of-one and half-a-dozen of the other.

I have done something similar before; I used a combination of techniques when I did my [old beta so the Semitics there are still a little weak, etc.]: over 200+ lyrics similar in idea to poems in that is one of the few times <br /> has semantic value/usage.

I mainly used Regular Expressions to do a batch Find and Replace in a similar fashion to above - saved loads of time. As I was using several different sources over several years… I also will have done similar (as post above) MS Word F and R at times.

Also another possible idea shudder you might consider is a web editor as quick way to alter a copy-and-paste of the poem plaintext - they should add the BR and P. There are several pros and cons to each method.

I would also use BR in preference to PRE on the basis that the semantic value of pre-formatted text isn’t as high as breaking down each paragraph as required, with line breaks to signify the next part of the poem. What I would say is if you do use BR, you should use it only when a logical line break should occur. This doesn’t always mean that every segment needs to be hooked onto the next line though, it means that you should just try and make it as readable as possible. :slight_smile:

Thanks a lot :slight_smile:
I’ll definitely try one of these methods.

With html semantics in mind, I strongly suggest the following link to structure the poetry properly!