Open kixxauth opened 13 years ago
Make is what I know, so that's what we got. I realize it's aging, but we aren't doing anything terribly complex with it either. I would like to get most of the building piped through a NodeJS script, but that's for fun, and make is for profit.
Rather than prepending and appending a header and footer, respectively, I'd like to try to use a "layout" file instead. I think I could do this by placing a keyword in a comment tag in a layout.html
file, something like:
<html><head></head>
<body>
<!-- #yield -->
</body>
</html>
I was thinking of doing this with sed
, but I gave up on it before. I am open to ideas.
Ugh.
Converting markdown files...
sed: 1: "s/<\!-- yield -->/<p><a ...": bad flag in substitute command: 'a'
sed: 1: "s/<\!-- yield -->/<h1>H ...": bad flag in substitute command: 'h'
It feels like I am doing this wrong.
Not much better:
sed: 1: "s:<\!-- yield -->:<p><a ...": unescaped newline inside substitute pattern
sed: 1: "s:<\!-- yield -->:<h1>H ...": unescaped newline inside substitute pattern
I'm outta my league here with system tools and bash scripting. I see what is happening, but have no idea what else to try.
It would seem that Perl better suits this task. As I understand it, it is a language more intended to manipulate text than bash is. There are other languages which are equally well suited. The scripting style of Perl inspired Ruby's, for instance, so Ruby would likely do as well. We are already using Perl to translate Markdown, though, so if we stick with Perl we don't add any dependencies.
If Perl would better suite this task, then you're right... so would Ruby, or Python, or even JavaScript.
I'm leaning in the direction of using a Ruby Markdown parser and doing the build with Rake or even moving to Jekyll http://jekyllrb.com/
I don't see us using Perl on a regular basis for any of our other projects, but I do think we have a better chance of using Ruby from time to time on projects like this one.
Aside: I'm a Ruby beginner, so not much help here until I get a day of free time to learn how to program in it.
If the suggestion I found in that link doesn't work then I'll take the opportunity to reengage with Rake. No time to try it now, though. Maybe tomorrow.
We now have a make script that runs our Markdown source through a parser and generates HTML. W00t!
Now we just need the generated HTML documents to pull in their prerequisite resources (CSS and images).
I think the CSS files need to be moved into the src/ dir and then copied into the dist/ dir by the build script at build time. That way our CSS will be tracked along with the Markdown source by Git. (The dist/ dir is not tracked by Git as configured in .gitignore)
Pulling these resources into the HTML is a matter of appending the proper HTML tags to the beginning of each HTML file.