From d5a12f19bcf508a1764ca5ab63e04e25a90a68ae Mon Sep 17 00:00:00 2001 From: Buck Evan Date: Mon, 23 Dec 2024 10:37:15 -0600 Subject: [PATCH 1/4] extend the --theme option to all themes also: configuration support for theme --- README.md | 10 ++++++++++ grip/api.py | 8 ++++---- grip/app.py | 26 ++++++++++++++++++-------- grip/command.py | 42 ++++++++++++++++++++++++++++-------------- grip/exceptions.py | 3 +++ grip/settings.py | 1 + 6 files changed, 64 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index be556d2..cdc9289 100644 --- a/README.md +++ b/README.md @@ -241,6 +241,16 @@ To customize Grip, create `~/.grip/settings.py`, then add one or more of the fol - `HOST`: The host to use when not provided as a CLI argument, `localhost` by default - `PORT`: The port to use when not provided as a CLI argument, `6419` by default +- `THEME`: The github theme to use for styling. Choose one of: + - `light` -- the default + - `dark` + - `dark_colorblind` + - `dark_dimmed` + - `dark_high_contrast` + - `dark_tritanopia` + - `light_colorblind` + - `light_high_contrast` + - `light_tritanopia` - `DEBUG`: Whether to use Flask's debugger when an error happens, `False` by default - `DEBUG_GRIP`: Prints extended information when an error happens, `False` by default - `API_URL`: Base URL for the github API, for example that of a Github Enterprise instance. `https://api.github.com` by default diff --git a/grip/api.py b/grip/api.py index 33b6ce0..271618b 100644 --- a/grip/api.py +++ b/grip/api.py @@ -13,7 +13,7 @@ def create_app(path=None, user_content=False, context=None, username=None, password=None, render_offline=False, render_wide=False, render_inline=False, api_url=None, title=None, text=None, - autorefresh=None, quiet=None, theme='light', grip_class=None): + autorefresh=None, quiet=None, theme=None, grip_class=None): """ Creates a Grip application with the specified overrides. """ @@ -49,7 +49,7 @@ def create_app(path=None, user_content=False, context=None, username=None, def serve(path=None, host=None, port=None, user_content=False, context=None, username=None, password=None, render_offline=False, render_wide=False, render_inline=False, api_url=None, title=None, - autorefresh=True, browser=False, quiet=None, theme='light', grip_class=None): + autorefresh=True, browser=False, quiet=None, theme=None, grip_class=None): """ Starts a server to render the specified file or directory containing a README. @@ -72,7 +72,7 @@ def clear_cache(grip_class=None): def render_page(path=None, user_content=False, context=None, username=None, password=None, render_offline=False, render_wide=False, render_inline=False, - api_url=None, title=None, text=None, quiet=None, theme='light', + api_url=None, title=None, text=None, quiet=None, theme=None, grip_class=None): """ Renders the specified markup text to an HTML page and returns it. @@ -97,7 +97,7 @@ def render_content(text, user_content=False, context=None, username=None, def export(path=None, user_content=False, context=None, username=None, password=None, render_offline=False, render_wide=False, render_inline=True, out_filename=None, - api_url=None, title=None, quiet=False, theme='light', grip_class=None): + api_url=None, title=None, quiet=False, theme=None, grip_class=None): """ Exports the rendered HTML to a file. """ diff --git a/grip/app.py b/grip/app.py index 25593bb..61562ec 100644 --- a/grip/app.py +++ b/grip/app.py @@ -31,7 +31,7 @@ from .browser import start_browser_when_ready from .constants import ( DEFAULT_GRIPHOME, DEFAULT_GRIPURL, STYLE_ASSET_URLS_INLINE_FORMAT) -from .exceptions import AlreadyRunningError, ReadmeNotFoundError +from .exceptions import AlreadyRunningError, ConfigurationError, ReadmeNotFoundError from .readers import DirectoryReader from .renderers import GitHubRenderer, ReadmeRenderer @@ -43,7 +43,7 @@ class Grip(Flask): """ def __init__(self, source=None, auth=None, renderer=None, assets=None, render_wide=None, render_inline=None, title=None, - autorefresh=None, quiet=None, theme='light', grip_url=None, + autorefresh=None, quiet=None, theme=None, grip_url=None, static_url_path=None, instance_path=None, **kwargs): # Defaults if source is None or isinstance(source, str_type): @@ -92,6 +92,8 @@ def __init__(self, source=None, auth=None, renderer=None, password = self.config['PASSWORD'] if username or password: auth = (username or '', password or '') + if theme is None: + theme = self.config['THEME'] # Thread-safe event to signal to the polling threads to exit self._run_mutex = threading.Lock() @@ -213,14 +215,22 @@ def _render_page(self, subpath=None): if self.autorefresh else None) - if self.theme == 'dark': + # the default values + data_color_mode = 'auto' + data_light_theme = 'light' + data_dark_theme = 'dark' + + if self.theme.startswith('dark'): data_color_mode = 'dark' - data_light_theme = 'light' - data_dark_theme = 'dark' - else: + data_dark_theme = self.theme + elif self.theme.startswith('light'): data_color_mode = 'light' - data_light_theme = 'light' - data_dark_theme = 'dark' + data_light_theme = self.theme + elif self.theme == 'auto': + data_color_mode = self.theme + else: + raise ConfigurationError("unexpected theme: %r" % self.theme) + return render_template( 'index.html', filename=self.reader.filename_for(subpath), diff --git a/grip/command.py b/grip/command.py index fc2028a..60508d0 100644 --- a/grip/command.py +++ b/grip/command.py @@ -39,30 +39,44 @@ the file changes. --quiet Do not print to the terminal. --theme= Theme to view markdown file (light mode or dark mode). - Valid options ("light", "dark"). Default: "light" + Default: "auto" Valid options: (as of writing) + - `auto` -- defaults to `light` + - `light` + - `dark` + - `dark_colorblind` + - `dark_dimmed` + - `dark_high_contrast` + - `dark_tritanopia` + - `light_colorblind` + - `light_high_contrast` + - `light_tritanopia` """ +from __future__ import annotations from __future__ import print_function -import sys +import errno import mimetypes import socket -import errno +import sys +from getpass import getpass from docopt import docopt -from getpass import getpass -from path_and_address import resolve, split_address +from path_and_address import resolve +from path_and_address import split_address from . import __version__ -from .api import clear_cache, export, serve +from .api import clear_cache +from .api import export +from .api import serve from .exceptions import ReadmeNotFoundError - usage = '\n\n\n'.join(__doc__.split('\n\n\n')[1:]) version = 'Grip ' + __version__ # Note: GitHub supports more than light mode and dark mode (exp: light-high-constrast, dark-high-constrast). -VALID_THEME_OPTIONS = ['light', 'dark'] +VALID_THEME_PREFIXES = ['auto', 'light', 'dark'] + def main(argv=None, force_utf8=True, patch_svg=True): """ @@ -106,14 +120,14 @@ def main(argv=None, force_utf8=True, patch_svg=True): password = getpass() # Parse theme argument - if args['--theme']: - if args['--theme'] in VALID_THEME_OPTIONS: - theme: str = args['--theme'] + theme: str | None = args["--theme"] + if theme: + for prefix in VALID_THEME_PREFIXES: + if theme.startswith(prefix): + break else: - print('Error: valid options for theme argument are "light", "dark"') + print('Error: invalid value for theme: %r', theme) return 1 - else: - theme = 'light' # Export to a file instead of running a server if args['--export']: diff --git a/grip/exceptions.py b/grip/exceptions.py index d923b2c..1737744 100644 --- a/grip/exceptions.py +++ b/grip/exceptions.py @@ -31,3 +31,6 @@ def __str__(self): return 'No README found at {0}'.format(self.path) return self.strerror + +class ConfigurationError(ValueError): + pass diff --git a/grip/settings.py b/grip/settings.py index 7d8ba08..0495120 100644 --- a/grip/settings.py +++ b/grip/settings.py @@ -14,6 +14,7 @@ CACHE_DIRECTORY = 'cache-{version}' AUTOREFRESH = True QUIET = False +THEME = 'auto' # Note: For security concerns, please don't save your GitHub password in your From 0253008a7c6be3662b815b283e4356df6c437392 Mon Sep 17 00:00:00 2001 From: Buck Evan Date: Mon, 23 Dec 2024 10:38:01 -0600 Subject: [PATCH 2/4] add a (empty) pyproject.toml, to allow "editable" install --- pyproject.toml | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..e69de29 From 20434a3a48285fcfc52d475223dc44381f15f164 Mon Sep 17 00:00:00 2001 From: Buck Evan Date: Mon, 23 Dec 2024 11:43:13 -0600 Subject: [PATCH 3/4] update tests --- tests/output/app/gfm-test-user-content.html | 2 +- tests/output/app/gfm-test-user-context.html | 2 +- tests/output/app/gfm-test.html | 152 ++++++------------ tests/output/app/simple-user-content.html | 2 +- tests/output/app/simple-user-context.html | 2 +- tests/output/app/simple.html | 2 +- tests/output/app/zero-user-content.html | 4 +- tests/output/app/zero-user-context.html | 4 +- tests/output/app/zero.html | 2 +- tests/output/raw/gfm-test-user-content.html | 76 ++++----- tests/output/raw/gfm-test-user-context.html | 76 ++++----- tests/output/raw/gfm-test.html | 150 ++++++----------- .../renderer/gfm-test-user-content.html | 76 ++++----- .../renderer/gfm-test-user-context.html | 76 ++++----- tests/output/renderer/gfm-test.html | 150 ++++++----------- tests/test_github.py | 16 +- 16 files changed, 326 insertions(+), 466 deletions(-) diff --git a/tests/output/app/gfm-test-user-content.html b/tests/output/app/gfm-test-user-content.html index ceff1ce..41fdc35 100644 --- a/tests/output/app/gfm-test-user-content.html +++ b/tests/output/app/gfm-test-user-content.html @@ -1,5 +1,5 @@ - + README.md - Grip diff --git a/tests/output/app/gfm-test-user-context.html b/tests/output/app/gfm-test-user-context.html index 4d6e3f5..c9107b4 100644 --- a/tests/output/app/gfm-test-user-context.html +++ b/tests/output/app/gfm-test-user-context.html @@ -1,5 +1,5 @@ - + gfm-test.md - Grip diff --git a/tests/output/app/gfm-test.html b/tests/output/app/gfm-test.html index d66758f..0dbae2c 100644 --- a/tests/output/app/gfm-test.html +++ b/tests/output/app/gfm-test.html @@ -1,5 +1,5 @@ - + gfm-test.md - Grip @@ -46,17 +46,15 @@

-

-GitHub Flavored Markdown Test

+

GitHub Flavored Markdown Test

This Markdown file contains all the features of GitHub Flavored Markdown for testing a renderer with.

The features are taken directly from Daring Fireball and GitHub Flavored Markdown, followed by a list of one-offs.

-

-Inline HTML

+

Inline HTML

- + @@ -65,13 +63,12 @@

E.g., you can’t use Markdown-style *emphasis* inside an HTML block.

-
Foo
+

Span-level HTML tags — e.g. <span>, <cite>, or <del> — can be used anywhere in a Markdown paragraph, list item, or header. If you want, you can even use HTML tags instead of Markdown formatting; e.g. if you’d prefer to use HTML <a> or <img> tags instead of Markdown’s link or image syntax, go right ahead.

-

-Testing span, cite, and del tags

+

Testing span, cite, and del tags

Testing span, cite, and del tags in a paragraph.

And each element in its own list item:

    @@ -79,8 +76,7 @@

  • This is within a cite tag.
  • This is within a del tag.
-

-Automatic escaping for special characters

+

Automatic escaping for special characters

-

-Paragraphs and line breaks

+

Paragraphs and line breaks

This is a normal paragraph.

This and the next sentence is separated by a single newline. This should be on the same line.

@@ -103,36 +98,26 @@

This should be two lines below.

These two paragraphs are separated by two <br /> tags.

This should be three lines below.

-

-Headers

+

Headers

Here are some headers followed by Lorem Ipsum.

-

-This is an H1 (Setext-style)

+

This is an H1 (Setext-style)

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

-

-This is an H2 (Setext-style)

+

This is an H2 (Setext-style)

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

The following are atx-style.

-

-This is an H1

+

This is an H1

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

-

-This is an H2

+

This is an H2

Mauris feugiat, augue vitae sollicitudin vulputate, neque arcu dapibus eros, eget semper lorem ex rhoncus nulla.

-

-This is an H3

+

This is an H3

Etiam sit amet orci sit amet dui mollis molestie.

-

-This is an H4

+

This is an H4

Cras et elit egestas, lacinia est eu, vestibulum enim.

-
-This is an H5
+
This is an H5

Phasellus sed suscipit quam.

-
-This is an H√36
+
This is an H√36

Nam rutrum imperdiet purus, sit amet porttitor augue tempor quis.

-

-Blockquotes

+

Blockquotes

Email-style blockquotes:

This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet, @@ -161,8 +146,7 @@

Blockquotes containing other Markdown elements:

-

-This is a header.

+

This is a header.

  1. This is the first list item.
  2. This is the second list item.
  3. @@ -171,10 +155,8 @@

    return shell_exec("echo $input | $markdown_script");
     

-

-Lists

-
-These three lists should be equivalent
+

Lists

+
These three lists should be equivalent

First:

  • Red
  • @@ -193,8 +175,7 @@
  • Green
  • Blue
-

-These three ordered lists should be equivalent

+

These three ordered lists should be equivalent

First:

  1. Bird
  2. @@ -213,8 +194,7 @@

  3. McHale
  4. Parish
-

-These two lists should be equivalent

+

These two lists should be equivalent

First:

  • Lorem ipsum dolor sit amet, consectetuer adipiscing elit. @@ -231,8 +211,7 @@

  • Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse id sem consectetuer libero luctus adipiscing.
-

-Paragraphs and lists

+

Paragraphs and lists

  • Bird
  • Magic
  • @@ -246,8 +225,7 @@

    Magic

-

-Paragraphs within lists

+

Paragraphs within lists

First:

  1. @@ -274,8 +252,7 @@

    Another item in the same list.

  2. -

    -Blockquote within a list

    +

    Blockquote within a list

    • A list item with a blockquote:

      @@ -285,8 +262,7 @@

    -

    -Code within a list

    +

    Code within a list

    • A list item with a code block:

      @@ -294,14 +270,12 @@

    -

    -Accidental lists

    +

    Accidental lists

    1. What a great season. (oops, I wanted a year, not a list)

    1986. What a great season. (whew! there we go)

    -

    -Code blocks

    +

    Code blocks

    This is a normal paragraph:

    This is a code block.
     
    @@ -323,18 +297,15 @@

    print('Code block') -
    -print('Pre block')
    +
    print('Pre block')
     
    -

    -Horizontal rules

    +

    Horizontal rules






    -

    -Links

    +

    Links

    Markdown supports two style of links: inline and reference.

    This is an example inline link.

    This link has no title attribute.

    @@ -349,8 +320,7 @@

  3. foo 4
  4. foo 5
  5. -

    -Emphasis

    +

    Emphasis

    • single asterisks
    • single underscores
    • @@ -359,8 +329,7 @@

    • unfriggingbelievable
    • *this text is surrounded by literal asterisks*
    -

    -Code

    +

    Code

    • Use the printf() function.
    • There is a literal backtick (`) here.
    • @@ -373,23 +342,20 @@

      &#8212; is the decimal-encoded equivalent of &mdash;

    -

    -Images

    +

    Images

      -
    • Alt text
    • -
    • Alt text
    • -
    • Alt text
    • +
    • Alt text
    • +
    • Alt text
    • +
    • Alt text
    • -   ← bigger & blurrier
    • +   ← bigger & blurrier
    -

    -Automatic links

    +

    Automatic links

    -

    -Backslash escapes

    +

    Backslash escapes

    • *literal asterisks*
    • \ backslash
    • @@ -405,35 +371,28 @@

    • . dot
    • ! exclamation mark
    -

    -GitHub Flavored Markdown

    +

    GitHub Flavored Markdown

    See GitHub Flavored Markdown for details.

    -

    -Multiple underscores in words

    +

    Multiple underscores in words

    • wow_great_stuff
    -

    -URL autolinking

    +

    URL autolinking

    http://joeyespo.com

    -

    -Strikethrough

    +

    Strikethrough

    Mistaken text.

    -

    -Fenced code blocks

    +

    Fenced code blocks

    function test() {
       console.log("notice the blank line before this function?");
     }
     
    -

    -Syntax highlighting

    +

    Syntax highlighting

    print('Hello!')
    console.log('JavaScript!');
    console.log('JavaScript (with js)!');
    console.log('No matching language, but looks like JavaScript.');
     
    -

    -Tables

    +

    Tables

    Simple:

    @@ -544,18 +503,14 @@

    -

    -HTML

    +

    HTML

    TODO: Test all allowed HTML tags.

    -

    -Writing on GitHub

    +

    Writing on GitHub

    See this article for details.

    -

    -Newlines

    +

    Newlines

    Roses are red Violets are Blue

    -

    -Task lists

    +

    Task lists

    • @mentions, #refs, links, formatting, and tags are supported
    • list syntax is required (any unordered or ordered list supported)
    • @@ -573,8 +528,7 @@

    • a separate task
    -

    -References

    +

    References

    • SHA: dbcd7a410ee7489acf92f40641a135fbcf52a768
    • User@SHA: joeyespo@dbcd7a410ee7489acf92f40641a135fbcf52a768
    • diff --git a/tests/output/app/simple-user-content.html b/tests/output/app/simple-user-content.html index 0c9086c..66b9bda 100644 --- a/tests/output/app/simple-user-content.html +++ b/tests/output/app/simple-user-content.html @@ -1,5 +1,5 @@ - + README.md - Grip diff --git a/tests/output/app/simple-user-context.html b/tests/output/app/simple-user-context.html index d462240..1b99f90 100644 --- a/tests/output/app/simple-user-context.html +++ b/tests/output/app/simple-user-context.html @@ -1,5 +1,5 @@ - + simple.md - Grip diff --git a/tests/output/app/simple.html b/tests/output/app/simple.html index 01b1213..340d3f2 100644 --- a/tests/output/app/simple.html +++ b/tests/output/app/simple.html @@ -1,5 +1,5 @@ - + simple.md - Grip diff --git a/tests/output/app/zero-user-content.html b/tests/output/app/zero-user-content.html index f55d337..b3157ba 100644 --- a/tests/output/app/zero-user-content.html +++ b/tests/output/app/zero-user-content.html @@ -1,5 +1,5 @@ - + zero.md - Grip @@ -111,4 +111,4 @@ } - \ No newline at end of file + diff --git a/tests/output/app/zero-user-context.html b/tests/output/app/zero-user-context.html index 3cdc47d..cbb4490 100644 --- a/tests/output/app/zero-user-context.html +++ b/tests/output/app/zero-user-context.html @@ -1,5 +1,5 @@ - + zero.md - Grip @@ -132,4 +132,4 @@ } - \ No newline at end of file + diff --git a/tests/output/app/zero.html b/tests/output/app/zero.html index cf43595..a803823 100644 --- a/tests/output/app/zero.html +++ b/tests/output/app/zero.html @@ -1,5 +1,5 @@ - + zero.md - Grip diff --git a/tests/output/raw/gfm-test-user-content.html b/tests/output/raw/gfm-test-user-content.html index 589808d..8e458d0 100644 --- a/tests/output/raw/gfm-test-user-content.html +++ b/tests/output/raw/gfm-test-user-content.html @@ -5,7 +5,7 @@

      GitHub Flavored Markdown Test

      and GitHub Flavored Markdown,
      followed by a list of one-offs.

      Inline HTML

      - +
      @@ -15,7 +15,7 @@

      Inline HTML

      E.g., you can’t use Markdown-style *emphasis* inside an HTML block. -
      Foo
      +

      Span-level HTML tags — e.g. <span>, <cite>, or <del> — can be used anywhere
      in a Markdown paragraph, list item, or header. If you want, you can even use HTML tags instead
      of Markdown formatting; e.g. if you’d prefer to use HTML <a> or <img> tags instead
      @@ -35,7 +35,7 @@

      Automatic escaping for special characters

    • 4 < 5 should render the same as 4 < 5

    Note that GitHub Flavored Markdown has URL autolinking, which will not
    -convert &amp;. So these two should yield different links:

    +convert &amp;. So these two should yield different links:

    • http://images.google.com/images?num=30&q=larry+bird
    • http://images.google.com/images?num=30&amp;q=larry+bird
    • @@ -44,11 +44,11 @@

      Paragraphs and line breaks

      This is a normal paragraph.

      This and the next sentence is separated by a single newline.
      This should be on the same line.

      -

      This and the next sentence is joined by a single <br />.

      +

      This and the next sentence is joined by a single <br />.

      This should be on a new line, directly below.

      -

      These two sentences are separated by two <br /> tags.


      +

      These two sentences are separated by two <br /> tags.


      This should be two lines below.

      -

      These two paragraphs are separated by two <br /> tags.

      +

      These two paragraphs are separated by two <br /> tags.

      This should be three lines below.

      Headers

      Here are some headers followed by Lorem Ipsum.

      @@ -104,7 +104,7 @@

      This is a header.

    • This is the second list item.

Here's some example code:

-
return shell_exec("echo $input | $markdown_script");
+
return shell_exec("echo $input | $markdown_script");
 

Lists

@@ -218,7 +218,7 @@

Code within a list

  • A list item with a code block:

    -
    <code goes here>
    +
    <code goes here>
     
@@ -229,15 +229,15 @@

Accidental lists

1986. What a great season. (whew! there we go)

Code blocks

This is a normal paragraph:

-
This is a code block.
+
This is a code block.
 

Here is an example of AppleScript:

-
tell application "Foo"
+
tell application "Foo"
     beep
 end tell
 

Markdown will handle the hassle of encoding the ampersands and angle brackets:

-
<div class="footer">
+
<div class="footer">
     &copy; 2004 Foo Corporation
 </div>
 
@@ -246,10 +246,10 @@ 

Code blocks

puts "some #{4-space-indent} code" end
- + print('Code block') -
print('Pre block')
+
print('Pre block')
 

Horizontal rules


@@ -283,19 +283,19 @@

Emphasis

Code

    -
  • Use the printf() function.
  • -
  • There is a literal backtick (`) here.
  • -
  • A single backtick in a code span: `
  • -
  • A backtick-delimited string in a code span: `foo`
  • -
  • Please don't use any <blink> tags.
  • -
  • &#8212; is the decimal-encoded equivalent of &mdash;
  • +
  • Use the printf() function.
  • +
  • There is a literal backtick (`) here.
  • +
  • A single backtick in a code span: `
  • +
  • A backtick-delimited string in a code span: `foo`
  • +
  • Please don't use any <blink> tags.
  • +
  • &#8212; is the decimal-encoded equivalent of &mdash;

Images

    -
  • Alt text
  • -
  • Alt text
  • -
  • Alt text
  • -
  •   ← bigger & blurrier
  • +
  • Alt text
  • +
  • Alt text
  • +
  • Alt text
  • +
  •   ← bigger & blurrier

Automatic links

    @@ -329,19 +329,19 @@

    URL autolinking

    Strikethrough

    Mistaken text.

    Fenced code blocks

    -
    function test() {
    +
    function test() {
       console.log("notice the blank line before this function?");
     }
     

    Syntax highlighting

    -
    print('Hello!')
    -
    console.log('JavaScript!');
    -
    console.log('JavaScript (with js)!');
    -
    console.log('No matching language, but looks like JavaScript.');
    +
    print('Hello!')
    +
    console.log('JavaScript!');
    +
    console.log('JavaScript (with js)!');
    +
    console.log('No matching language, but looks like JavaScript.');
     

    Tables

    Simple:

    - +
    @@ -358,9 +358,9 @@

    Tables

    -
    First Header Content Cell
    +

    Pipes:

    - +
    @@ -377,9 +377,9 @@

    Tables

    -
    First Header Content Cell
    +

    Unmatched:

    - +
    @@ -396,9 +396,9 @@

    Tables

    -
    Name Closes a window
    +

    Inner Markdown:

    - +
    @@ -415,9 +415,9 @@

    Tables

    -
    Name Closes a window
    +

    Alignment:

    - +
    @@ -447,7 +447,7 @@

    Tables

    -
    Left-Aligned
    +

    HTML

    TODO: Test all allowed HTML tags.

    Writing on GitHub

    diff --git a/tests/output/raw/gfm-test-user-context.html b/tests/output/raw/gfm-test-user-context.html index cfc5e42..118674d 100644 --- a/tests/output/raw/gfm-test-user-context.html +++ b/tests/output/raw/gfm-test-user-context.html @@ -5,7 +5,7 @@

    GitHub Flavored Markdown Test

    and GitHub Flavored Markdown,
    followed by a list of one-offs.

    Inline HTML

    - +
    @@ -15,7 +15,7 @@

    Inline HTML

    E.g., you can’t use Markdown-style *emphasis* inside an HTML block. -
    Foo
    +

    Span-level HTML tags — e.g. <span>, <cite>, or <del> — can be used anywhere
    in a Markdown paragraph, list item, or header. If you want, you can even use HTML tags instead
    of Markdown formatting; e.g. if you’d prefer to use HTML <a> or <img> tags instead
    @@ -35,7 +35,7 @@

    Automatic escaping for special characters

  • 4 < 5 should render the same as 4 < 5

Note that GitHub Flavored Markdown has URL autolinking, which will not
-convert &amp;. So these two should yield different links:

+convert &amp;. So these two should yield different links:

  • http://images.google.com/images?num=30&q=larry+bird
  • http://images.google.com/images?num=30&amp;q=larry+bird
  • @@ -44,11 +44,11 @@

    Paragraphs and line breaks

    This is a normal paragraph.

    This and the next sentence is separated by a single newline.
    This should be on the same line.

    -

    This and the next sentence is joined by a single <br />.

    +

    This and the next sentence is joined by a single <br />.

    This should be on a new line, directly below.

    -

    These two sentences are separated by two <br /> tags.


    +

    These two sentences are separated by two <br /> tags.


    This should be two lines below.

    -

    These two paragraphs are separated by two <br /> tags.

    +

    These two paragraphs are separated by two <br /> tags.

    This should be three lines below.

    Headers

    Here are some headers followed by Lorem Ipsum.

    @@ -104,7 +104,7 @@

    This is a header.

  • This is the second list item.
  • Here's some example code:

    -
    return shell_exec("echo $input | $markdown_script");
    +
    return shell_exec("echo $input | $markdown_script");
     

    Lists

    @@ -218,7 +218,7 @@

    Code within a list

    • A list item with a code block:

      -
      <code goes here>
      +
      <code goes here>
       
    @@ -229,15 +229,15 @@

    Accidental lists

    1986. What a great season. (whew! there we go)

    Code blocks

    This is a normal paragraph:

    -
    This is a code block.
    +
    This is a code block.
     

    Here is an example of AppleScript:

    -
    tell application "Foo"
    +
    tell application "Foo"
         beep
     end tell
     

    Markdown will handle the hassle of encoding the ampersands and angle brackets:

    -
    <div class="footer">
    +
    <div class="footer">
         &copy; 2004 Foo Corporation
     </div>
     
    @@ -246,10 +246,10 @@ 

    Code blocks

    puts "some #{4-space-indent} code" end
    - + print('Code block') -
    print('Pre block')
    +
    print('Pre block')
     

    Horizontal rules


    @@ -283,19 +283,19 @@

    Emphasis

Code

    -
  • Use the printf() function.
  • -
  • There is a literal backtick (`) here.
  • -
  • A single backtick in a code span: `
  • -
  • A backtick-delimited string in a code span: `foo`
  • -
  • Please don't use any <blink> tags.
  • -
  • &#8212; is the decimal-encoded equivalent of &mdash;
  • +
  • Use the printf() function.
  • +
  • There is a literal backtick (`) here.
  • +
  • A single backtick in a code span: `
  • +
  • A backtick-delimited string in a code span: `foo`
  • +
  • Please don't use any <blink> tags.
  • +
  • &#8212; is the decimal-encoded equivalent of &mdash;

Images

    -
  • Alt text
  • -
  • Alt text
  • -
  • Alt text
  • -
  •   ← bigger & blurrier
  • +
  • Alt text
  • +
  • Alt text
  • +
  • Alt text
  • +
  •   ← bigger & blurrier

Automatic links

    @@ -329,19 +329,19 @@

    URL autolinking

    Strikethrough

    Mistaken text.

    Fenced code blocks

    -
    function test() {
    +
    function test() {
       console.log("notice the blank line before this function?");
     }
     

    Syntax highlighting

    -
    print('Hello!')
    -
    console.log('JavaScript!');
    -
    console.log('JavaScript (with js)!');
    -
    console.log('No matching language, but looks like JavaScript.');
    +
    print('Hello!')
    +
    console.log('JavaScript!');
    +
    console.log('JavaScript (with js)!');
    +
    console.log('No matching language, but looks like JavaScript.');
     

    Tables

    Simple:

    - +
    @@ -358,9 +358,9 @@

    Tables

    -
    First Header Content Cell
    +

    Pipes:

    - +
    @@ -377,9 +377,9 @@

    Tables

    -
    First Header Content Cell
    +

    Unmatched:

    - +
    @@ -396,9 +396,9 @@

    Tables

    -
    Name Closes a window
    +

    Inner Markdown:

    - +
    @@ -415,9 +415,9 @@

    Tables

    -
    Name Closes a window
    +

    Alignment:

    - +
    @@ -447,7 +447,7 @@

    Tables

    -
    Left-Aligned
    +

    HTML

    TODO: Test all allowed HTML tags.

    Writing on GitHub

    diff --git a/tests/output/raw/gfm-test.html b/tests/output/raw/gfm-test.html index dc4e13a..6eb42fe 100644 --- a/tests/output/raw/gfm-test.html +++ b/tests/output/raw/gfm-test.html @@ -1,14 +1,12 @@ -

    -GitHub Flavored Markdown Test

    +

    GitHub Flavored Markdown Test

    This Markdown file contains all the features of GitHub Flavored Markdown for testing a renderer with.

    The features are taken directly from Daring Fireball and GitHub Flavored Markdown, followed by a list of one-offs.

    -

    -Inline HTML

    +

    Inline HTML

    - + @@ -17,13 +15,12 @@

    E.g., you can’t use Markdown-style *emphasis* inside an HTML block.

    -
    Foo
    +

    Span-level HTML tags — e.g. <span>, <cite>, or <del> — can be used anywhere in a Markdown paragraph, list item, or header. If you want, you can even use HTML tags instead of Markdown formatting; e.g. if you’d prefer to use HTML <a> or <img> tags instead of Markdown’s link or image syntax, go right ahead.

    -

    -Testing span, cite, and del tags

    +

    Testing span, cite, and del tags

    Testing span, cite, and del tags in a paragraph.

    And each element in its own list item:

      @@ -31,8 +28,7 @@

    • This is within a cite tag.
    • This is within a del tag.
    -

    -Automatic escaping for special characters

    +

    Automatic escaping for special characters

    -

    -Paragraphs and line breaks

    +

    Paragraphs and line breaks

    This is a normal paragraph.

    This and the next sentence is separated by a single newline. This should be on the same line.

    @@ -55,36 +50,26 @@

    This should be two lines below.

    These two paragraphs are separated by two <br /> tags.

    This should be three lines below.

    -

    -Headers

    +

    Headers

    Here are some headers followed by Lorem Ipsum.

    -

    -This is an H1 (Setext-style)

    +

    This is an H1 (Setext-style)

    Lorem ipsum dolor sit amet, consectetur adipiscing elit.

    -

    -This is an H2 (Setext-style)

    +

    This is an H2 (Setext-style)

    Lorem ipsum dolor sit amet, consectetur adipiscing elit.

    The following are atx-style.

    -

    -This is an H1

    +

    This is an H1

    Lorem ipsum dolor sit amet, consectetur adipiscing elit.

    -

    -This is an H2

    +

    This is an H2

    Mauris feugiat, augue vitae sollicitudin vulputate, neque arcu dapibus eros, eget semper lorem ex rhoncus nulla.

    -

    -This is an H3

    +

    This is an H3

    Etiam sit amet orci sit amet dui mollis molestie.

    -

    -This is an H4

    +

    This is an H4

    Cras et elit egestas, lacinia est eu, vestibulum enim.

    -
    -This is an H5
    +
    This is an H5

    Phasellus sed suscipit quam.

    -
    -This is an H√36
    +
    This is an H√36

    Nam rutrum imperdiet purus, sit amet porttitor augue tempor quis.

    -

    -Blockquotes

    +

    Blockquotes

    Email-style blockquotes:

    This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet, @@ -113,8 +98,7 @@

    Blockquotes containing other Markdown elements:

    -

    -This is a header.

    +

    This is a header.

    1. This is the first list item.
    2. This is the second list item.
    3. @@ -123,10 +107,8 @@

      return shell_exec("echo $input | $markdown_script");
       

    -

    -Lists

    -
    -These three lists should be equivalent
    +

    Lists

    +
    These three lists should be equivalent

    First:

    • Red
    • @@ -145,8 +127,7 @@
    • Green
    • Blue
    -

    -These three ordered lists should be equivalent

    +

    These three ordered lists should be equivalent

    First:

    1. Bird
    2. @@ -165,8 +146,7 @@

    3. McHale
    4. Parish
    -

    -These two lists should be equivalent

    +

    These two lists should be equivalent

    First:

    • Lorem ipsum dolor sit amet, consectetuer adipiscing elit. @@ -183,8 +163,7 @@

    • Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse id sem consectetuer libero luctus adipiscing.
    -

    -Paragraphs and lists

    +

    Paragraphs and lists

    • Bird
    • Magic
    • @@ -198,8 +177,7 @@

      Magic

    -

    -Paragraphs within lists

    +

    Paragraphs within lists

    First:

    1. @@ -226,8 +204,7 @@

      Another item in the same list.

-

-Blockquote within a list

+

Blockquote within a list

  • A list item with a blockquote:

    @@ -237,8 +214,7 @@

-

-Code within a list

+

Code within a list

  • A list item with a code block:

    @@ -246,14 +222,12 @@

-

-Accidental lists

+

Accidental lists

  1. What a great season. (oops, I wanted a year, not a list)

1986. What a great season. (whew! there we go)

-

-Code blocks

+

Code blocks

This is a normal paragraph:

This is a code block.
 
@@ -275,18 +249,15 @@

print('Code block') -
-print('Pre block')
+
print('Pre block')
 
-

-Horizontal rules

+

Horizontal rules






-

-Links

+

Links

Markdown supports two style of links: inline and reference.

This is an example inline link.

This link has no title attribute.

@@ -301,8 +272,7 @@

  • foo 4
  • foo 5
  • -

    -Emphasis

    +

    Emphasis

    • single asterisks
    • single underscores
    • @@ -311,8 +281,7 @@

    • unfriggingbelievable
    • *this text is surrounded by literal asterisks*
    -

    -Code

    +

    Code

    • Use the printf() function.
    • There is a literal backtick (`) here.
    • @@ -325,23 +294,20 @@

      &#8212; is the decimal-encoded equivalent of &mdash;

    -

    -Images

    +

    Images

      -
    • Alt text
    • -
    • Alt text
    • -
    • Alt text
    • +
    • Alt text
    • +
    • Alt text
    • +
    • Alt text
    • -   ← bigger & blurrier
    • +   ← bigger & blurrier
    -

    -Automatic links

    +

    Automatic links

    -

    -Backslash escapes

    +

    Backslash escapes

    • *literal asterisks*
    • \ backslash
    • @@ -357,35 +323,28 @@

    • . dot
    • ! exclamation mark
    -

    -GitHub Flavored Markdown

    +

    GitHub Flavored Markdown

    See GitHub Flavored Markdown for details.

    -

    -Multiple underscores in words

    +

    Multiple underscores in words

    • wow_great_stuff
    -

    -URL autolinking

    +

    URL autolinking

    http://joeyespo.com

    -

    -Strikethrough

    +

    Strikethrough

    Mistaken text.

    -

    -Fenced code blocks

    +

    Fenced code blocks

    function test() {
       console.log("notice the blank line before this function?");
     }
     
    -

    -Syntax highlighting

    +

    Syntax highlighting

    print('Hello!')
    console.log('JavaScript!');
    console.log('JavaScript (with js)!');
    console.log('No matching language, but looks like JavaScript.');
     
    -

    -Tables

    +

    Tables

    Simple:

    @@ -496,18 +455,14 @@

    -

    -HTML

    +

    HTML

    TODO: Test all allowed HTML tags.

    -

    -Writing on GitHub

    +

    Writing on GitHub

    See this article for details.

    -

    -Newlines

    +

    Newlines

    Roses are red Violets are Blue

    -

    -Task lists

    +

    Task lists

    • [x] @mentions, #refs, links, formatting, and tags are supported
    • [x] list syntax is required (any unordered or ordered list supported)
    • @@ -525,8 +480,7 @@

    • [x] a separate task
    -

    -References

    +

    References

    • SHA: dbcd7a410ee7489acf92f40641a135fbcf52a768
    • User@SHA: joeyespo@dbcd7a410ee7489acf92f40641a135fbcf52a768
    • diff --git a/tests/output/renderer/gfm-test-user-content.html b/tests/output/renderer/gfm-test-user-content.html index 589808d..8e458d0 100644 --- a/tests/output/renderer/gfm-test-user-content.html +++ b/tests/output/renderer/gfm-test-user-content.html @@ -5,7 +5,7 @@

      GitHub Flavored Markdown Test

      and GitHub Flavored Markdown,
      followed by a list of one-offs.

      Inline HTML

      - +
      @@ -15,7 +15,7 @@

      Inline HTML

      E.g., you can’t use Markdown-style *emphasis* inside an HTML block. -
      Foo
      +

      Span-level HTML tags — e.g. <span>, <cite>, or <del> — can be used anywhere
      in a Markdown paragraph, list item, or header. If you want, you can even use HTML tags instead
      of Markdown formatting; e.g. if you’d prefer to use HTML <a> or <img> tags instead
      @@ -35,7 +35,7 @@

      Automatic escaping for special characters

    • 4 < 5 should render the same as 4 < 5

    Note that GitHub Flavored Markdown has URL autolinking, which will not
    -convert &amp;. So these two should yield different links:

    +convert &amp;. So these two should yield different links:

    • http://images.google.com/images?num=30&q=larry+bird
    • http://images.google.com/images?num=30&amp;q=larry+bird
    • @@ -44,11 +44,11 @@

      Paragraphs and line breaks

      This is a normal paragraph.

      This and the next sentence is separated by a single newline.
      This should be on the same line.

      -

      This and the next sentence is joined by a single <br />.

      +

      This and the next sentence is joined by a single <br />.

      This should be on a new line, directly below.

      -

      These two sentences are separated by two <br /> tags.


      +

      These two sentences are separated by two <br /> tags.


      This should be two lines below.

      -

      These two paragraphs are separated by two <br /> tags.

      +

      These two paragraphs are separated by two <br /> tags.

      This should be three lines below.

      Headers

      Here are some headers followed by Lorem Ipsum.

      @@ -104,7 +104,7 @@

      This is a header.

    • This is the second list item.
    • Here's some example code:

      -
      return shell_exec("echo $input | $markdown_script");
      +
      return shell_exec("echo $input | $markdown_script");
       

      Lists

      @@ -218,7 +218,7 @@

      Code within a list

      • A list item with a code block:

        -
        <code goes here>
        +
        <code goes here>
         
      @@ -229,15 +229,15 @@

      Accidental lists

      1986. What a great season. (whew! there we go)

      Code blocks

      This is a normal paragraph:

      -
      This is a code block.
      +
      This is a code block.
       

      Here is an example of AppleScript:

      -
      tell application "Foo"
      +
      tell application "Foo"
           beep
       end tell
       

      Markdown will handle the hassle of encoding the ampersands and angle brackets:

      -
      <div class="footer">
      +
      <div class="footer">
           &copy; 2004 Foo Corporation
       </div>
       
      @@ -246,10 +246,10 @@ 

      Code blocks

      puts "some #{4-space-indent} code" end
      - + print('Code block') -
      print('Pre block')
      +
      print('Pre block')
       

      Horizontal rules


      @@ -283,19 +283,19 @@

      Emphasis

    Code

      -
    • Use the printf() function.
    • -
    • There is a literal backtick (`) here.
    • -
    • A single backtick in a code span: `
    • -
    • A backtick-delimited string in a code span: `foo`
    • -
    • Please don't use any <blink> tags.
    • -
    • &#8212; is the decimal-encoded equivalent of &mdash;
    • +
    • Use the printf() function.
    • +
    • There is a literal backtick (`) here.
    • +
    • A single backtick in a code span: `
    • +
    • A backtick-delimited string in a code span: `foo`
    • +
    • Please don't use any <blink> tags.
    • +
    • &#8212; is the decimal-encoded equivalent of &mdash;

    Images

      -
    • Alt text
    • -
    • Alt text
    • -
    • Alt text
    • -
    •   ← bigger & blurrier
    • +
    • Alt text
    • +
    • Alt text
    • +
    • Alt text
    • +
    •   ← bigger & blurrier

    Automatic links

      @@ -329,19 +329,19 @@

      URL autolinking

      Strikethrough

      Mistaken text.

      Fenced code blocks

      -
      function test() {
      +
      function test() {
         console.log("notice the blank line before this function?");
       }
       

      Syntax highlighting

      -
      print('Hello!')
      -
      console.log('JavaScript!');
      -
      console.log('JavaScript (with js)!');
      -
      console.log('No matching language, but looks like JavaScript.');
      +
      print('Hello!')
      +
      console.log('JavaScript!');
      +
      console.log('JavaScript (with js)!');
      +
      console.log('No matching language, but looks like JavaScript.');
       

      Tables

      Simple:

      - +
      @@ -358,9 +358,9 @@

      Tables

      -
      First Header Content Cell
      +

      Pipes:

      - +
      @@ -377,9 +377,9 @@

      Tables

      -
      First Header Content Cell
      +

      Unmatched:

      - +
      @@ -396,9 +396,9 @@

      Tables

      -
      Name Closes a window
      +

      Inner Markdown:

      - +
      @@ -415,9 +415,9 @@

      Tables

      -
      Name Closes a window
      +

      Alignment:

      - +
      @@ -447,7 +447,7 @@

      Tables

      -
      Left-Aligned
      +

      HTML

      TODO: Test all allowed HTML tags.

      Writing on GitHub

      diff --git a/tests/output/renderer/gfm-test-user-context.html b/tests/output/renderer/gfm-test-user-context.html index cfc5e42..118674d 100644 --- a/tests/output/renderer/gfm-test-user-context.html +++ b/tests/output/renderer/gfm-test-user-context.html @@ -5,7 +5,7 @@

      GitHub Flavored Markdown Test

      and GitHub Flavored Markdown,
      followed by a list of one-offs.

      Inline HTML

      - +
      @@ -15,7 +15,7 @@

      Inline HTML

      E.g., you can’t use Markdown-style *emphasis* inside an HTML block. -
      Foo
      +

      Span-level HTML tags — e.g. <span>, <cite>, or <del> — can be used anywhere
      in a Markdown paragraph, list item, or header. If you want, you can even use HTML tags instead
      of Markdown formatting; e.g. if you’d prefer to use HTML <a> or <img> tags instead
      @@ -35,7 +35,7 @@

      Automatic escaping for special characters

    • 4 < 5 should render the same as 4 < 5

    Note that GitHub Flavored Markdown has URL autolinking, which will not
    -convert &amp;. So these two should yield different links:

    +convert &amp;. So these two should yield different links:

    • http://images.google.com/images?num=30&q=larry+bird
    • http://images.google.com/images?num=30&amp;q=larry+bird
    • @@ -44,11 +44,11 @@

      Paragraphs and line breaks

      This is a normal paragraph.

      This and the next sentence is separated by a single newline.
      This should be on the same line.

      -

      This and the next sentence is joined by a single <br />.

      +

      This and the next sentence is joined by a single <br />.

      This should be on a new line, directly below.

      -

      These two sentences are separated by two <br /> tags.


      +

      These two sentences are separated by two <br /> tags.


      This should be two lines below.

      -

      These two paragraphs are separated by two <br /> tags.

      +

      These two paragraphs are separated by two <br /> tags.

      This should be three lines below.

      Headers

      Here are some headers followed by Lorem Ipsum.

      @@ -104,7 +104,7 @@

      This is a header.

    • This is the second list item.
    • Here's some example code:

      -
      return shell_exec("echo $input | $markdown_script");
      +
      return shell_exec("echo $input | $markdown_script");
       

      Lists

      @@ -218,7 +218,7 @@

      Code within a list

      • A list item with a code block:

        -
        <code goes here>
        +
        <code goes here>
         
      @@ -229,15 +229,15 @@

      Accidental lists

      1986. What a great season. (whew! there we go)

      Code blocks

      This is a normal paragraph:

      -
      This is a code block.
      +
      This is a code block.
       

      Here is an example of AppleScript:

      -
      tell application "Foo"
      +
      tell application "Foo"
           beep
       end tell
       

      Markdown will handle the hassle of encoding the ampersands and angle brackets:

      -
      <div class="footer">
      +
      <div class="footer">
           &copy; 2004 Foo Corporation
       </div>
       
      @@ -246,10 +246,10 @@ 

      Code blocks

      puts "some #{4-space-indent} code" end
      - + print('Code block') -
      print('Pre block')
      +
      print('Pre block')
       

      Horizontal rules


      @@ -283,19 +283,19 @@

      Emphasis

    Code

      -
    • Use the printf() function.
    • -
    • There is a literal backtick (`) here.
    • -
    • A single backtick in a code span: `
    • -
    • A backtick-delimited string in a code span: `foo`
    • -
    • Please don't use any <blink> tags.
    • -
    • &#8212; is the decimal-encoded equivalent of &mdash;
    • +
    • Use the printf() function.
    • +
    • There is a literal backtick (`) here.
    • +
    • A single backtick in a code span: `
    • +
    • A backtick-delimited string in a code span: `foo`
    • +
    • Please don't use any <blink> tags.
    • +
    • &#8212; is the decimal-encoded equivalent of &mdash;

    Images

      -
    • Alt text
    • -
    • Alt text
    • -
    • Alt text
    • -
    •   ← bigger & blurrier
    • +
    • Alt text
    • +
    • Alt text
    • +
    • Alt text
    • +
    •   ← bigger & blurrier

    Automatic links

      @@ -329,19 +329,19 @@

      URL autolinking

      Strikethrough

      Mistaken text.

      Fenced code blocks

      -
      function test() {
      +
      function test() {
         console.log("notice the blank line before this function?");
       }
       

      Syntax highlighting

      -
      print('Hello!')
      -
      console.log('JavaScript!');
      -
      console.log('JavaScript (with js)!');
      -
      console.log('No matching language, but looks like JavaScript.');
      +
      print('Hello!')
      +
      console.log('JavaScript!');
      +
      console.log('JavaScript (with js)!');
      +
      console.log('No matching language, but looks like JavaScript.');
       

      Tables

      Simple:

      - +
      @@ -358,9 +358,9 @@

      Tables

      -
      First Header Content Cell
      +

      Pipes:

      - +
      @@ -377,9 +377,9 @@

      Tables

      -
      First Header Content Cell
      +

      Unmatched:

      - +
      @@ -396,9 +396,9 @@

      Tables

      -
      Name Closes a window
      +

      Inner Markdown:

      - +
      @@ -415,9 +415,9 @@

      Tables

      -
      Name Closes a window
      +

      Alignment:

      - +
      @@ -447,7 +447,7 @@

      Tables

      -
      Left-Aligned
      +

      HTML

      TODO: Test all allowed HTML tags.

      Writing on GitHub

      diff --git a/tests/output/renderer/gfm-test.html b/tests/output/renderer/gfm-test.html index 885d940..53b40b4 100644 --- a/tests/output/renderer/gfm-test.html +++ b/tests/output/renderer/gfm-test.html @@ -1,14 +1,12 @@ -

      -GitHub Flavored Markdown Test

      +

      GitHub Flavored Markdown Test

      This Markdown file contains all the features of GitHub Flavored Markdown for testing a renderer with.

      The features are taken directly from Daring Fireball and GitHub Flavored Markdown, followed by a list of one-offs.

      -

      -Inline HTML

      +

      Inline HTML

      - + @@ -17,13 +15,12 @@

      E.g., you can’t use Markdown-style *emphasis* inside an HTML block.

      -
      Foo
      +

      Span-level HTML tags — e.g. <span>, <cite>, or <del> — can be used anywhere in a Markdown paragraph, list item, or header. If you want, you can even use HTML tags instead of Markdown formatting; e.g. if you’d prefer to use HTML <a> or <img> tags instead of Markdown’s link or image syntax, go right ahead.

      -

      -Testing span, cite, and del tags

      +

      Testing span, cite, and del tags

      Testing span, cite, and del tags in a paragraph.

      And each element in its own list item:

        @@ -31,8 +28,7 @@

      • This is within a cite tag.
      • This is within a del tag.
      -

      -Automatic escaping for special characters

      +

      Automatic escaping for special characters

      -

      -Paragraphs and line breaks

      +

      Paragraphs and line breaks

      This is a normal paragraph.

      This and the next sentence is separated by a single newline. This should be on the same line.

      @@ -55,36 +50,26 @@

      This should be two lines below.

      These two paragraphs are separated by two <br /> tags.

      This should be three lines below.

      -

      -Headers

      +

      Headers

      Here are some headers followed by Lorem Ipsum.

      -

      -This is an H1 (Setext-style)

      +

      This is an H1 (Setext-style)

      Lorem ipsum dolor sit amet, consectetur adipiscing elit.

      -

      -This is an H2 (Setext-style)

      +

      This is an H2 (Setext-style)

      Lorem ipsum dolor sit amet, consectetur adipiscing elit.

      The following are atx-style.

      -

      -This is an H1

      +

      This is an H1

      Lorem ipsum dolor sit amet, consectetur adipiscing elit.

      -

      -This is an H2

      +

      This is an H2

      Mauris feugiat, augue vitae sollicitudin vulputate, neque arcu dapibus eros, eget semper lorem ex rhoncus nulla.

      -

      -This is an H3

      +

      This is an H3

      Etiam sit amet orci sit amet dui mollis molestie.

      -

      -This is an H4

      +

      This is an H4

      Cras et elit egestas, lacinia est eu, vestibulum enim.

      -
      -This is an H5
      +
      This is an H5

      Phasellus sed suscipit quam.

      -
      -This is an H√36
      +
      This is an H√36

      Nam rutrum imperdiet purus, sit amet porttitor augue tempor quis.

      -

      -Blockquotes

      +

      Blockquotes

      Email-style blockquotes:

      This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet, @@ -113,8 +98,7 @@

      Blockquotes containing other Markdown elements:

      -

      -This is a header.

      +

      This is a header.

      1. This is the first list item.
      2. This is the second list item.
      3. @@ -123,10 +107,8 @@

        return shell_exec("echo $input | $markdown_script");
         

      -

      -Lists

      -
      -These three lists should be equivalent
      +

      Lists

      +
      These three lists should be equivalent

      First:

      • Red
      • @@ -145,8 +127,7 @@
      • Green
      • Blue
      -

      -These three ordered lists should be equivalent

      +

      These three ordered lists should be equivalent

      First:

      1. Bird
      2. @@ -165,8 +146,7 @@

      3. McHale
      4. Parish
      -

      -These two lists should be equivalent

      +

      These two lists should be equivalent

      First:

      • Lorem ipsum dolor sit amet, consectetuer adipiscing elit. @@ -183,8 +163,7 @@

      • Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse id sem consectetuer libero luctus adipiscing.
      -

      -Paragraphs and lists

      +

      Paragraphs and lists

      • Bird
      • Magic
      • @@ -198,8 +177,7 @@

        Magic

      -

      -Paragraphs within lists

      +

      Paragraphs within lists

      First:

      1. @@ -226,8 +204,7 @@

        Another item in the same list.

    -

    -Blockquote within a list

    +

    Blockquote within a list

    • A list item with a blockquote:

      @@ -237,8 +214,7 @@

    -

    -Code within a list

    +

    Code within a list

    • A list item with a code block:

      @@ -246,14 +222,12 @@

    -

    -Accidental lists

    +

    Accidental lists

    1. What a great season. (oops, I wanted a year, not a list)

    1986. What a great season. (whew! there we go)

    -

    -Code blocks

    +

    Code blocks

    This is a normal paragraph:

    This is a code block.
     
    @@ -275,18 +249,15 @@

    print('Code block') -
    -print('Pre block')
    +
    print('Pre block')
     
    -

    -Horizontal rules

    +

    Horizontal rules






    -

    -Links

    +

    Links

    Markdown supports two style of links: inline and reference.

    This is an example inline link.

    This link has no title attribute.

    @@ -301,8 +272,7 @@

  • foo 4
  • foo 5
  • -

    -Emphasis

    +

    Emphasis

    • single asterisks
    • single underscores
    • @@ -311,8 +281,7 @@

    • unfriggingbelievable
    • *this text is surrounded by literal asterisks*
    -

    -Code

    +

    Code

    • Use the printf() function.
    • There is a literal backtick (`) here.
    • @@ -325,23 +294,20 @@

      &#8212; is the decimal-encoded equivalent of &mdash;

    -

    -Images

    +

    Images

      -
    • Alt text
    • -
    • Alt text
    • -
    • Alt text
    • +
    • Alt text
    • +
    • Alt text
    • +
    • Alt text
    • -   ← bigger & blurrier
    • +   ← bigger & blurrier
    -

    -Automatic links

    +

    Automatic links

    -

    -Backslash escapes

    +

    Backslash escapes

    • *literal asterisks*
    • \ backslash
    • @@ -357,35 +323,28 @@

    • . dot
    • ! exclamation mark
    -

    -GitHub Flavored Markdown

    +

    GitHub Flavored Markdown

    See GitHub Flavored Markdown for details.

    -

    -Multiple underscores in words

    +

    Multiple underscores in words

    • wow_great_stuff
    -

    -URL autolinking

    +

    URL autolinking

    http://joeyespo.com

    -

    -Strikethrough

    +

    Strikethrough

    Mistaken text.

    -

    -Fenced code blocks

    +

    Fenced code blocks

    function test() {
       console.log("notice the blank line before this function?");
     }
     
    -

    -Syntax highlighting

    +

    Syntax highlighting

    print('Hello!')
    console.log('JavaScript!');
    console.log('JavaScript (with js)!');
    console.log('No matching language, but looks like JavaScript.');
     
    -

    -Tables

    +

    Tables

    Simple:

    @@ -496,18 +455,14 @@

    -

    -HTML

    +

    HTML

    TODO: Test all allowed HTML tags.

    -

    -Writing on GitHub

    +

    Writing on GitHub

    See this article for details.

    -

    -Newlines

    +

    Newlines

    Roses are red Violets are Blue

    -

    -Task lists

    +

    Task lists

    • @mentions, #refs, links, formatting, and tags are supported
    • list syntax is required (any unordered or ordered list supported)
    • @@ -525,8 +480,7 @@

    • a separate task
    -

    -References

    +

    References

    • SHA: dbcd7a410ee7489acf92f40641a135fbcf52a768
    • User@SHA: joeyespo@dbcd7a410ee7489acf92f40641a135fbcf52a768
    • diff --git a/tests/test_github.py b/tests/test_github.py index 28ef0cd..9996081 100644 --- a/tests/test_github.py +++ b/tests/test_github.py @@ -10,6 +10,7 @@ from __future__ import print_function, unicode_literals import os +from pathlib import Path import pytest import requests @@ -67,16 +68,13 @@ def test_github_user_context(input_markdown, output_user_context): @pytest.mark.assumption -def test_styles_exist(tmpdir): - GitHubAssetManager(str(tmpdir)).retrieve_styles('http://dummy/') - assert len(tmpdir.listdir()) > 2 +def test_styles_exist(tmp_path: Path): + GitHubAssetManager(tmp_path).retrieve_styles("http://dummy/") - files = list(map(lambda f: os.path.basename(str(f)), tmpdir.listdir())) - assert any(f.startswith('github-') and f.endswith('.css') for f in files) - assert any( - f.startswith('frameworks-') and f.endswith('.css') for f in files) - - # TODO: Test that style retrieval actually parsed CSS with regex + files = set(tmp_path.iterdir()) + assert len(files) > 2 + assert any(f.name.startswith("github-") and f.name.endswith(".css") for f in files) + assert any(f.name.startswith("primer-react.") and f.name.endswith(".module.css") for f in files) # TODO: Test that local images show up in the browser From 63d31de328f98f9f48a75c6c36217ddfe625c6db Mon Sep 17 00:00:00 2001 From: Buck Evan Date: Mon, 23 Dec 2024 11:51:25 -0600 Subject: [PATCH 4/4] run tests for pull requests --- .github/workflows/test.yaml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..f11cfd9 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,29 @@ +name: Python Tests + +on: + push: + branches: + - "**" # This will trigger on any branch push + pull_request: + branches: + - "**" # This will trigger on PRs targeting any branch + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.x" # This will use the latest stable Python 3 + + - name: Install dependencies + run: | + pip install -r requirements-test.txt + + - name: Run tests + run: | + pytest -vv