I will be publishing a blog in my website. Frequently I will write fairly long entries in a word processor. My site has custom html and css tags -- for example, -div class="blog_post_para"-.
I will dump text into a .txt document (which I save as .html when I'm finished), but adding the tags manually to each paragraph and header will be slow and tedious.
Is there any tool available that can automatically format the paragraphs with "div" tags at the start and /div at the end. The same would be true for paragraph p and /p> tags.
I don't want to use an IDE like Dreamweaver. I just want to format code in a .txt document or a text document saved as .html.
I can output the word processor document to html, but all the styles are inline, and they can't match the custom styles on my site because the word processor doesn't know their names. Default styles won't do -- I have my own custom css classes.
It would also have to replace apostrophes with [amp]#39; and dashes with —
I was going to do it programmatically (in Python), which is probably the most custom solution, but it will take some time.
Is there such a tool?
Since this is ending up on a webpage, why not use JavaScript? A very simple function can turn the plain text into properly formatted tags, or anything else you'd like. For example:
function contentToHtml(text) {
return text
.split('\n\n')
.map(paragraph => `<p>${paragraph}</p>`)
.join('')
}
This function assumes you hit enter twice when separating paragraphs. It will take in your text and wrap each paragraph in <p> tags.
You may want to look into Jekyll, it's a static site generator and I think it's pretty much designed for what you're asking, particularly since you're publishing a blog.
As a bonus, it integrates nicely with Github Pages, so you can get free hosting.
https://help.github.com/en/articles/using-jekyll-as-a-static-site-generator-with-github-pages
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With