Compare commits
No commits in common. "42fe1d3805544fc911f97ff2ed410c07f1f258ae" and "448e72c0d70d8c7373381d3acff51f7cc991afd2" have entirely different histories.
42fe1d3805
...
448e72c0d7
|
@ -2,7 +2,6 @@ import MarkdownIt from "markdown-it";
|
||||||
import MarkdownItFootnote from "markdown-it-footnote";
|
import MarkdownItFootnote from "markdown-it-footnote";
|
||||||
import slugify from "@sindresorhus/slugify";
|
import slugify from "@sindresorhus/slugify";
|
||||||
import * as util from "./util";
|
import * as util from "./util";
|
||||||
import { URL } from "url";
|
|
||||||
|
|
||||||
const md = new MarkdownIt({
|
const md = new MarkdownIt({
|
||||||
highlight: util.highlight,
|
highlight: util.highlight,
|
||||||
|
@ -14,7 +13,7 @@ md.use(MarkdownItFootnote);
|
||||||
|
|
||||||
// Inserts heading anchors
|
// Inserts heading anchors
|
||||||
// Based on https://github.com/valeriangalliat/markdown-it-anchor
|
// Based on https://github.com/valeriangalliat/markdown-it-anchor
|
||||||
md.core.ruler.push("header anchor", (state) => {
|
md.core.ruler.push("anchor", (state) => {
|
||||||
const tokens = state.tokens;
|
const tokens = state.tokens;
|
||||||
|
|
||||||
tokens
|
tokens
|
||||||
|
@ -49,29 +48,6 @@ md.core.ruler.push("header anchor", (state) => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Adds data-link attributes to anchor elements
|
|
||||||
const defaultRenderer = md.renderer.rules.link_open || function(tokens, index, options, env, self) {
|
|
||||||
return self.renderToken(tokens, index, options);
|
|
||||||
};
|
|
||||||
md.renderer.rules.link_open = function(tokens, index, options, env, self) {
|
|
||||||
const href = tokens[index].attrGet("href");
|
|
||||||
if (href != null) {
|
|
||||||
try {
|
|
||||||
const parsed = new URL(href);
|
|
||||||
const formattedPathname = parsed.pathname === "/" ? "" : parsed.pathname;//.length > 20 ? parsed.pathname.substr(0, 20) + "..." : parsed.pathname;
|
|
||||||
let formatted = `${parsed.hostname}${formattedPathname}`;
|
|
||||||
if (formatted.length > 40) {
|
|
||||||
formatted = formatted.substr(0, 40) + "...";
|
|
||||||
}
|
|
||||||
tokens[index].attrPush(["data-link", formatted]);
|
|
||||||
} catch (e) {
|
|
||||||
// URL constructor throws on invalid URLs (such as ones that only contain a fragment), so swallow those exceptions
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return defaultRenderer(tokens, index, options, env, self);
|
|
||||||
};
|
|
||||||
|
|
||||||
export function render(text: string): string {
|
export function render(text: string): string {
|
||||||
return md.render(text);
|
return md.render(text);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ body {
|
||||||
background-color: var(--content-background-color);
|
background-color: var(--content-background-color);
|
||||||
font-family: $sansSerif;
|
font-family: $sansSerif;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
line-height: 1.6;
|
line-height: 1.5;
|
||||||
color: var(--ui-text-color);
|
color: var(--ui-text-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ article {
|
||||||
// Markdown decorations
|
// Markdown decorations
|
||||||
@media (min-width: 768px) {
|
@media (min-width: 768px) {
|
||||||
a::before { content: "["; }
|
a::before { content: "["; }
|
||||||
a::after { content: "](" attr(data-link) ")"; word-wrap: break-word; }
|
a::after { content: "](" attr(href) ")"; word-wrap: break-word; }
|
||||||
a::before, a::after {
|
a::before, a::after {
|
||||||
color: var(--secondary-ui-text-color);
|
color: var(--secondary-ui-text-color);
|
||||||
font-family: $monospace;
|
font-family: $monospace;
|
||||||
|
|
|
@ -15,7 +15,7 @@ I strongly believe that the best way to learn a programming language (especially
|
||||||
|
|
||||||
By this point, it was almost December, so I decided I was going to try to do the [Advent of Code](https://adventofcode) problems only using Elixir. These challenges were more difficult than the Exercism ones, but they provided the same benefit of letting me get experience actually writing Elixir and solving problems with it an isolated context, without a whole bunch of moving parts.
|
By this point, it was almost December, so I decided I was going to try to do the [Advent of Code](https://adventofcode) problems only using Elixir. These challenges were more difficult than the Exercism ones, but they provided the same benefit of letting me get experience actually writing Elixir and solving problems with it an isolated context, without a whole bunch of moving parts.
|
||||||
|
|
||||||
I knew what I ultimately wanted to do with Elixir was build web apps, so after that I went through the official [Phoenix Guide](https://hexdocs.pm/phoenix/overview.html) which explains the overall architecture of the Phoenix framework and shows you how a bunch of common patterns and techniques for building webapps with it.
|
I knew what I ultimately wanted to do with Elixir was build web apps, so after that I went through the official [Phoenix Guide](https://exercism.io/tracks/elixir) which explains the overall architecture of the Phoenix framework and shows you how a bunch of common patterns and techniques for building webapps with it.
|
||||||
|
|
||||||
Lastly, and most importantly, I actually started building projects using Elixir. The first one I started was [frenzy](https://git.shadowfacts.net/shadowfacts/frenzy), an RSS aggregator I built using Phoenix and Ecto. Originally, the project was a couple hundred lines of shoddily written JS. I wrote it even before I started learning Elixir, inteding it to be a stopgap. As I was learning Elixir, I knew this project was what it was building up to, so as read things and did programming exercises, I noticed things that I thought would become useful once I got around to rewriting frenzy in Elixir.
|
Lastly, and most importantly, I actually started building projects using Elixir. The first one I started was [frenzy](https://git.shadowfacts.net/shadowfacts/frenzy), an RSS aggregator I built using Phoenix and Ecto. Originally, the project was a couple hundred lines of shoddily written JS. I wrote it even before I started learning Elixir, inteding it to be a stopgap. As I was learning Elixir, I knew this project was what it was building up to, so as read things and did programming exercises, I noticed things that I thought would become useful once I got around to rewriting frenzy in Elixir.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue