diff --git a/public/content/rules.md b/public/content/rules.md index c665df0..f0f22c2 100644 --- a/public/content/rules.md +++ b/public/content/rules.md @@ -5,7 +5,7 @@ Basic Rules The goal of the game is to attack your opponent directly five times. Each time a player is attacked directly, they place the top card of their deck face up in a separate pile called the **damage zone**. Once there are five cards in a player's damage zone, that player loses the game. -The game takes place on a 5 by 7 grid (wider than it is long) called the **battlefield**. Players start the game with a face down **deck** of at least 40 cards, with no more than 3 copies of any one card, except for **Basics** (no limit) and **Singletons** (maximum of 1). Players draw 5 cards, decide to **mulligan** or not (see [Mulligans](#Mulligans)), then take turns by placing certain cards on the closest row of the battlefield, known as their **entry zone**. If there are no empty spaces in a player's entry zone, excluding movable **units** that player owns, then the player cannot play a new card and loses the game. A player also loses the game if they try to draw a card from their deck while it is empty. +The game takes place on a 5 by 7 grid (wider than it is long) called the **battlefield**. Players start the game with a face down **deck** of at least 40 cards, with no more than 3 copies of any one card, except for **Basics** (no limit) and **Singletons** (maximum of 1). Players draw 5 cards, decide to **mulligan** or not (see [Mulligans](#mulligans)), then take turns by placing certain cards on the closest row of the battlefield, known as their **entry zone**. If there are no empty spaces in a player's entry zone, excluding movable **units** that player owns, then the player cannot play a new card and loses the game. A player also loses the game if they try to draw a card from their deck while it is empty. Each unit you control may **move and/or attack** once per turn. A unit cannot move or attack in the same turn it was played, unless it has **haste**. If a unit moves, it must attack immediately, or forfit the attack for the turn. Units cannot move after attacking. diff --git a/public/index.html b/public/index.html index a7f2b52..d80491b 100644 --- a/public/index.html +++ b/public/index.html @@ -11,6 +11,6 @@
- + \ No newline at end of file diff --git a/src/pages/about.jsx b/src/pages/about.jsx index f16f3e8..d1ff32e 100644 --- a/src/pages/about.jsx +++ b/src/pages/about.jsx @@ -1,5 +1,6 @@ import React from "react"; import ReactMarkdown from "react-markdown"; +import MarkdownRenderers from "../utilities/markdown_renderers.js"; class About extends React.Component { constructor(props) { @@ -29,7 +30,7 @@ class About extends React.Component { render() { return (
- +
); } diff --git a/src/pages/landing.jsx b/src/pages/landing.jsx index d1c3fc6..75b3147 100644 --- a/src/pages/landing.jsx +++ b/src/pages/landing.jsx @@ -1,5 +1,6 @@ import React from "react"; import ReactMarkdown from "react-markdown"; +import MarkdownRenderers from "../utilities/markdown_renderers.js"; class Landing extends React.Component { constructor(props) { @@ -29,7 +30,7 @@ class Landing extends React.Component { render() { return (
- +
); } diff --git a/src/pages/rules.jsx b/src/pages/rules.jsx index a6b3b10..a96ac7c 100644 --- a/src/pages/rules.jsx +++ b/src/pages/rules.jsx @@ -1,5 +1,6 @@ import React from "react"; import ReactMarkdown from "react-markdown"; +import MarkdownRenderers from "../utilities/markdown_renderers.js"; class Rules extends React.Component { constructor(props) { @@ -29,7 +30,7 @@ class Rules extends React.Component { render() { return (
- +
); } diff --git a/src/utilities/markdown_renderers.js b/src/utilities/markdown_renderers.js new file mode 100644 index 0000000..23f00be --- /dev/null +++ b/src/utilities/markdown_renderers.js @@ -0,0 +1,17 @@ +import React from "react"; + +//https://github.com/rexxars/react-markdown/issues/69 +function headingRenderer(props) { + function flatten(text, child) { + return typeof child === 'string' ? text + child : React.Children.toArray(child.props.children).reduce(flatten, text); + } + + let children = React.Children.toArray(props.children); + let text = children.reduce(flatten, ''); + let slug = text.toLowerCase().replace(/\W/g, '-'); + return React.createElement('h' + props.level, {id: slug}, props.children); +} + +export default { + heading: headingRenderer +}; \ No newline at end of file