Categories
Software Development

Automating HTML5 Generation With AsciiDoctor

If you’re a documentation nerd or somewhat planning to create content for publishing, surely you will encounter ASCII Doc. ASCII Doc is being use by different publishing giants like O’Reilly to create books and content.

One problem I encountered is generating HTML documents from asciidoc format. So how do I automate it?

Better to die fighting for freedom then be a prisoner all the days of your life.

— Bob Marley.

Prerequisites

  • Ruby 2.5 and above

So how do we render HTML5 from ASCII Doc?

We proceed by getting all the required gems. The first step is get the file watcher to watch for changes.

gem install asciidoctor guard guard-shell guard-livereload yajl-ruby

The livereload gem watch changes in the file system. Also, you may need to install companion browser extension.

After the installation of Chrome Extension, you need to check “Allow access to file URLs” checkbox in More Tools > Extensions > Live Reload Details in order for it to work with local file URLs.

Then we create a Guardfile with the contents below.

require "asciidoctor"
guard "shell" do
	watch(/^solidity\.adoc$/) {|m|
		Asciidoctor.convert_file m[0]
	}
end
guard "livereload" do
	watch(%r{^.+\.(css|js|html)$})
end

The first guard block converts file to HTML5. Then after that the second guard block watches for file changes and reloads browser.

When all is done start the guard process to monitor and serve files.

guard start

That’s it guys we created our workflow for generating HTML5 using the asciidoctor format. Hit like if you like, subs if you love and as always live life. Hope you guys, enjoyed this article!

By Edward Fitz Abucay

"How long is forever?"

I'm a software engineer with a passion for innovating and creating products, especially for startups in the web3 and blockchain space. I'm always excited to learn and work with new technologies, and I'm committed to delivering high-quality solutions that meet the needs of my clients or users.

In my free time, I enjoy listening to music of all genres, but classical music holds a special place in my heart. I find it both inspiring and calming, and it helps me to stay focused and creative. I'm also an avid reader of books and manga, and I enjoy discovering new authors and stories.

As a software engineer, I have a strong technical background with experience in various programming languages, frameworks, and tools. I'm always striving to improve my skills and stay up-to-date with the latest trends and best practices. I love working with startups, especially those in the web3 and blockchain space, because I believe that these technologies have the potential to revolutionize the way we live and work.

Overall, I'm a dedicated and driven individual with a wide range of interests and skills. I believe that my passion for software engineering, combined with my love of music and reading, makes me a well-rounded and adaptable professional.

Leave a Reply

Your email address will not be published. Required fields are marked *