Skip to content

Commit

Permalink
use blockquote for rule text, handle subcategories as Examples
Browse files Browse the repository at this point in the history
  • Loading branch information
mburns committed Jul 8, 2017
1 parent 868b3fa commit 5e845d9
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions nomic.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ func readRule(filename string, dir string) *Rule {
// convert line from byte array to string
str := fmt.Sprintf("%s\n", line)

// eat blank lines
// rn := regexp.MustCompile("^$")
// check(err)
// n := rn.FindStringSubmatch(str)
// if len(n) > 0 {
// continue
// }

// grab (sub)heading name
r := regexp.MustCompile("^#+ ([A-Za-z]+)")
check(err)
Expand All @@ -179,7 +187,8 @@ func readRule(filename string, dir string) *Rule {
// append line to correct string
switch step {
case "Text":
body.Text = body.Text + str
// TODO : remove hack by prepending 4 spaces directly to the Rule text
body.Text = body.Text + " " + str
case "Example":
body.Examples = body.Examples + str
case "Original":
Expand All @@ -189,7 +198,9 @@ func readRule(filename string, dir string) *Rule {
case "Copyright":
copyright = copyright + str
default:
panic("unrecognized escape character")
body.Examples = body.Examples + str

// panic("unrecognized escape character")
}
}

Expand Down Expand Up @@ -222,8 +233,9 @@ func writeRules(rules []Rule) {

// TODO : concat all rule.Body.Text
dat = "# Rules\n\n"

for _, v := range rules {
dat = dat + fmt.Sprintf("### [%d](rules/rule%d.md)\n\n```%s```\n\n", v.Metadata.Number, v.Metadata.Number, v.Body.Text)
dat = dat + fmt.Sprintf("[#%d](rules/rule%d.md): %s\n", v.Metadata.Number, v.Metadata.Number, v.Body.Text)
}
err := ioutil.WriteFile("RULES.md", []byte(dat), 0644)
check(err)
Expand Down

0 comments on commit 5e845d9

Please sign in to comment.