-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example of using pandoc to inject stylesheets into the head #822
base: gh-pages
Are you sure you want to change the base?
Conversation
@cycomachead WDYT of this approach? It:
Markdown has excellent integration with github and github pages, and is easier to read and write than HTML. Using Markdown will make it a lot easier to refactor the common loader and stylesheet code to be separate from content. I can also pandoc --from html --to markdown --fail-if-warnings course.md --metadata title="title" --metadata-file=config.json course/cs10_sp21.html (note from is html and to is markdown) |
Thanks Chris for working on this! This is pretty interesting, but I do have a couple of primarily usability concerns, and one maintainability one. But, honestly this is pretty close to something I think we could work with. Usability:
Maintainability Otherwise, are there any "build systems" sitegens that exist using Pandoc? I'm not against pandoc as tool -- we might even start to rely on it for conversion of pages to individual word documents. Maybe this is some useful context, and where I am thinking about some potential opportunities: Two other enhancements that would be nice at some point:
I think I want to delay a wholesale conversion to markdown for a bit, but it's definitely on the list of things that could make writing easier. One thing we've been mulling over is whether reST might be better, which is at least an easy option with pandoc. though markdown certainly is an option still |
Excellent, glad to hear it. Let's keep iterating!
In almost all cases you don't actually need to run the compile, as all it does is optimize the style sheets. However, I do think a
I agree that the $ part is a bit annoying.
I could add in a sed script that replaces $ with $$. And lint check that no more
I guess? pandoc seems directly suited what this project wants though - a way to convert content in a one-off way for static deployment on a website. I have no experience with jinja or liquid, but they seem to be meant for dynamic web apps (at least liquid claims that).
I'm not sure I see what downside you're worried about.
Probably? I only learned about pandoc while writing https://browser.engineering. It seems like a pretty simple and efficient tool for this kind of job. I am very happy with it for that purpose. In fact, it has easily supported embedded HTML widgets we added recently (for markdown, but still).
It does appear that the only way to do non-fully-static builds with gh-pages right now is via Jekyll. I have never used Jekyll though, do you think that's a good solution?
Just curious: is this for faster load times?
What kind of sharing do you need? mixing pages from multiple sources into one site? If that's the need, can you satisfy it by making multiple sites and linking them to each other? |
Hi, WDYT? I'm open to suggestions. |
The current files aren't really usable without compiling; you really do need the CSS to read the page as users see it. The workflow for a lot of the folks working on curriculum is to write a bit and view it in the browser. So, ideally something would watch files and also serve Plus, in a way, I think if we can assume that everything is built, then we can drop the
jQuery may go one day, but c'mon that's separate. :) And while I'm a fan of Paul Irish's 'you might not need query' and the like, it still has its place. :) As for the prompt, my prompt is personally a 👉, but
My experience tends to be that Makefiles get more complex over time, and the number of people who are great with them are slim. There's nothing that stands out as terribly complex right now, though I fully admit it would have taken me much longer to write the same makefile (I assume). So, this may be more preference than anything.
Cool! That's a great example, and keep linking to the book. It's a good reminder to read through it. The source makes some clever use of Lua plugins, which seem like a fairly reasonable path for customization. (I could imagine things in the future like specifying
I think after a few days, I'm more keen to try pandoc. I like the looks of the repo for the book. Just for reference https://bjc.berkeley.edu ( https://github.com/beautyjoy/beautyjoy.github.io ) is a jekyll site -- and so far it works fine for that purpose. The main thing is that we get an auto-build, but for bjc-r we could use a GitHub Action (or other CI) that builds the site on merge and pushes to a branch.
S3 is primarily to get us out of the business of running a web server as much as possible. (We've got things deployed right now on a "semi-managed" Apache instance.. and it's becoming a pain to do things like debug caching, gather logs, etc)
Well we also have bjc-edc/bjc-r and at this point the content is pretty separate, and there's a couple of (separate) projects which may have forked that repository...but not necessarily with the intention of upstreaming changes. I guess that's partially why |
loader.js will load those style sheets, so all that's needed is to inline loader.js. I agree that this prototype is slightly hacky though (also the $$ comment below..)
(The jquery comment was just a joke :))
Different layouts for the same markdown page, you mean?
Yep, agreed.
Cool. How about something like converting content incrementally over to Markdown? |
Plan of record, unless I hear otherwise: I think I'll make a PR that converts exactly one HTML file to markdown, plus a Makefile similar to what is in this PR, plus a similar deploy mechanism to the www/ directory. |
This PR does the following:
Add a Makefile, with one target: "site". "make site" will copy all content from bjc to a www/ directory, and inject stylesheets and scripts into the head for any files that have the right template markers. Other files will be untouched.
Modifies one example to demonstrate the concept of injecting via a template (cs10_sp21.html).
Fixes a few instances where the $ special template character appeared in existing content.
When deploying to the live site, the site should be rooted at the www/ directory.
This PR is similar to https://github.com/beautyjoy/bjc-r/pull/800, except that it uses a templated way of injecting the scripts, plus a new deployment directory, rather than modifying in-place.
If this PR were landed, subsequent steps would be:
<head>
section.Further future changes could include migrating content to markdown gradually and introducing more pandoc templates to render them into HTML.