Skip to content

Commit

Permalink
[doc] Almost all .md docs parse with new cmark using lazylex.html.
Browse files Browse the repository at this point in the history
Exception: doc/help-index.md, which needs to use ``` blocks.
  • Loading branch information
Andy Chu committed Dec 28, 2019
1 parent 17e7056 commit d75a1c4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
6 changes: 4 additions & 2 deletions build/doc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,10 @@ all-help() {
mkdir -p $TEXT_DIR
rm -v -f $TEXT_DIR/*

help-index-html $HTML_DIR
log 'index text done'
if false; then
help-index-html $HTML_DIR
log 'help-index-html done'
fi

split-and-render doc/help.md

Expand Down
12 changes: 8 additions & 4 deletions doc/command-vs-expression-mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,20 @@ Right I should have clarified – they don’t turn globbing back on. It’s jus

It’s exactly like the difference between:

from glob import glob; glob('*.py') # yes glob
os.listdir('*.py') # no glob because it's not how listdir() works
```python
from glob import glob; glob('*.py') # yes glob
os.listdir('*.py') # no glob because it's not how listdir() works
```

in Python. Single quoted strings in Oil are just like string literals in Python. Does that make sense?

I’m not sure what you mean by myEcho? Both of these work in Oil just like they
do in sh:

echo *
echo '*'
```sh
echo *
echo '*'
```

Because you’ve never entered expression mode. You’re still in command mode.

9 changes: 9 additions & 0 deletions lazylex/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ def log(msg, *args):
print(msg, file=sys.stderr)


class LexError(Exception):
def __init__(self, s, pos):
self.s = s
self.pos = pos

def __str__(self):
return '(LexError %r)' % (self.s[self.pos : self.pos + 20])


class Output(object):
"""
Takes an underlying input buffer and an output file. Maintains a position in
Expand Down
11 changes: 8 additions & 3 deletions lazylex/oil_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def ExpandLinks(s):
out.SkipTo(href_end)

elif tok_id == html.Invalid:
raise RuntimeError(s[start_pos : end_pos])
raise html.LexError(s, start_pos)

start_pos = end_pos

Expand Down Expand Up @@ -217,7 +217,12 @@ def HighlightCode(s):
code_lexer.PrintHighlighted(out)

out.SkipTo(slash_code_left)
elif 1:

elif css_class == 'language-oil':
# TODO: Write an Oil syntax highlighter.
pass

else:
# Here's we're REMOVING the original <pre><code>
# Pygments gives you a <pre> already

Expand All @@ -241,7 +246,7 @@ def HighlightCode(s):
f.write('<!-- done pygments -->\n')

elif tok_id == html.Invalid:
raise RuntimeError(s[start_pos : end_pos])
raise html.LexError(s, start_pos)

start_pos = end_pos

Expand Down

0 comments on commit d75a1c4

Please sign in to comment.