Skip to content
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

Added support for Google Typograms #2379

Merged
merged 5 commits into from
Apr 30, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added support for typograms
Signed-off-by: George Araujo <george.gcac@gmail.com>
george-gca committed Apr 30, 2024
commit 99660d02e41a773a4bdd44af6adda8b958e5d117
23 changes: 23 additions & 0 deletions _includes/scripts/typograms.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{% if page.typograms %}
<script src="{{ '/assets/js/typograms.js' | relative_url | bust_file_cache }}"></script>

<script>
/* Create typogram as another node and hide the code block, appending the typogram node after it
this is done to enable retrieving the code again when changing theme between light/dark */
document.onreadystatechange = () => {
if (document.readyState === 'complete') {
document.querySelectorAll('pre>code.language-typograms').forEach((elem) => {
const texData = elem.textContent;
const parent = elem.parentElement.parentElement;
/* create typograms node */
let typogram = document.createElement('pre');
typogram.classList.add('typogram');
const svg = create("\n" + texData, 0.3, false);
typogram.appendChild(svg);
parent.appendChild(typogram);
parent.removeChild(elem.parentElement);
});
}
};
</script>
{% endif %}
1 change: 1 addition & 0 deletions _layouts/default.liquid
Original file line number Diff line number Diff line change
@@ -61,6 +61,7 @@
{% include scripts/echarts.liquid %}
{% include scripts/vega.liquid %}
{% include scripts/tikzjax.liquid %}
{% include scripts/typograms.liquid %}
{% include scripts/misc.liquid %}
{% include scripts/badges.liquid %}
{% include scripts/mathjax.liquid %}
27 changes: 27 additions & 0 deletions _posts/2024-04-29-typograms.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
layout: post
title: a post with typograms
date: 2024-04-29 23:36:10
description: this is what included typograms code could look like
tags: formatting diagrams
categories: sample-posts
typograms: true
---

This is an example post with some [typograms](https://github.com/google/typograms/) code.

````markdown
```typograms
+----+
| |---> My first diagram!
+----+
```
````

Which generates:

```typograms
+----+
| |---> My first diagram!
+----+
```
1,468 changes: 1,468 additions & 0 deletions assets/js/typograms.js

Large diffs are not rendered by default.