├── plim ├── adapters │ ├── __init__.py │ ├── babelplugin.py │ └── pyramid_renderer.py ├── unportable.py ├── util.py ├── errors.py ├── extensions.py ├── __init__.py ├── console.py └── syntax.py ├── tests ├── adapters │ ├── __init__.py │ └── test_babelplugin.py ├── fixtures │ ├── early_return_test.plim │ ├── coffee_test.plim │ ├── early_return_result.mako │ ├── no_filtering_result.mako │ ├── until_test.plim │ ├── no_filtering_test.plim │ ├── unicode_attributes_test.plim │ ├── unicode_attributes_result.mako │ ├── until_result.mako │ ├── scss_result.mako │ ├── with_test.plim │ ├── with_result.mako │ ├── unless_result.mako │ ├── coffee_result.mako │ ├── unless_test.plim │ ├── handlebars_test.plim │ ├── linebreak_result.mako │ ├── linebreak_test.plim │ ├── comment_result.mako │ ├── dynamic_attributes_test.plim │ ├── try_test.plim │ ├── multiline_variable_result.mako │ ├── stylus_result.mako │ ├── handlebars_result.mako │ ├── scss_test.plim │ ├── try_result.mako │ ├── explicit_space_result.mako │ ├── style_script_result.mako │ ├── call_test.plim │ ├── style_script_test.plim │ ├── stylus_test.plim │ ├── explicit_space_test.plim │ ├── call_result.mako │ ├── pipe_result.mako │ ├── inline_conditions_test.plim │ ├── comment_test.plim │ ├── multiline_variable_test.plim │ ├── mako_text_test.plim │ ├── while_result.mako │ ├── for_result.mako │ ├── while_test.plim │ ├── for_test.plim │ ├── mako_text_result.mako │ ├── inline_conditions_result.mako │ ├── for_result.dtl │ ├── pipe_test.plim │ ├── inline_loop_test.plim │ ├── embedded_result.mako │ ├── one_liners_result.mako │ ├── one_liners_test.plim │ ├── if_result.mako │ ├── embedded_test.plim │ ├── plim_multiline_tag_result.mako │ ├── if_test.plim │ ├── dynamic_attributes_result.mako │ ├── if_result.dtl │ ├── inline_loop_result.mako │ ├── def_block_result.mako │ ├── def_block_test.plim │ ├── plim_multiline_tag_test.plim │ ├── plim_line_result.mako │ ├── python_result.mako │ ├── plim_line_test.plim │ ├── babelplugin_test.plim │ ├── literal_one_liners_result.mako │ ├── python_test.plim │ ├── literal_one_liners_test.plim │ ├── reST_test.plim │ └── reST_result.mako ├── cli_fixtures │ ├── custom_parser_template.plim │ └── custom_parser_module.py ├── django_test │ ├── fixtures │ │ └── if_test.plim │ └── __init__.py ├── test_cli.py └── __init__.py ├── MANIFEST.in ├── shell.nix ├── docs ├── changes.rst ├── authors.rst ├── license.rst ├── related.rst ├── locale │ ├── zh_CN │ │ └── LC_MESSAGES │ │ │ ├── cli.po │ │ │ ├── license.po │ │ │ ├── authors.po │ │ │ ├── related.po │ │ │ ├── index.po │ │ │ ├── frameworks.po │ │ │ ├── differences.po │ │ │ ├── extensions.po │ │ │ └── changes.po │ ├── cli.pot │ ├── license.pot │ ├── authors.pot │ ├── related.pot │ ├── index.pot │ ├── frameworks.pot │ ├── differences.pot │ ├── extensions.pot │ └── changes.pot ├── cli.rst ├── frameworks.rst ├── differences.rst ├── index.rst ├── make.bat ├── Makefile ├── conf.py └── extensions.rst ├── package.json ├── .github ├── FUNDING.yml └── workflows │ └── ci.yml ├── requirements-test.txt ├── AUTHORS ├── .coveragerc ├── nixpkgs └── default.nix ├── .gitignore ├── setup.cfg ├── .editorconfig ├── requirements.txt ├── Makefile ├── pytest.ini ├── LICENSE ├── README.rst ├── default.nix ├── setup.py └── CHANGES /plim/adapters/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/adapters/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include README* LICENSE CHANGES *.txt -------------------------------------------------------------------------------- /shell.nix: -------------------------------------------------------------------------------- 1 | {}: (import ./default.nix {}).devEnv 2 | -------------------------------------------------------------------------------- /docs/changes.rst: -------------------------------------------------------------------------------- 1 | .. module:: plim 2 | 3 | .. include:: ../CHANGES 4 | -------------------------------------------------------------------------------- /tests/fixtures/early_return_test.plim: -------------------------------------------------------------------------------- 1 | - return 2 | -continue 3 | -break -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "stylus": "^0.59.0" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /tests/fixtures/coffee_test.plim: -------------------------------------------------------------------------------- 1 | -coffee 2 | number = 100 3 | opposite = true -------------------------------------------------------------------------------- /tests/fixtures/early_return_result.mako: -------------------------------------------------------------------------------- 1 | <% return %> 2 | <% continue %> 3 | <% break %> -------------------------------------------------------------------------------- /tests/fixtures/no_filtering_result.mako: -------------------------------------------------------------------------------- 1 | ${value|n}${value|n} ${value |n,u}${value |n,u,h} -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [avanov] 4 | -------------------------------------------------------------------------------- /tests/fixtures/until_test.plim: -------------------------------------------------------------------------------- 1 | - until value 2 | Test 3 | 4 | -until \ 5 | value 6 | Test -------------------------------------------------------------------------------- /tests/fixtures/no_filtering_test.plim: -------------------------------------------------------------------------------- 1 | == value 2 | ==, value 3 | 4 | == value |u 5 | ==, value | u,h -------------------------------------------------------------------------------- /requirements-test.txt: -------------------------------------------------------------------------------- 1 | pytest 2 | coverage 3 | pytest-cov 4 | 5 | mypy 6 | types-docutils 7 | types-setuptools 8 | -------------------------------------------------------------------------------- /tests/fixtures/unicode_attributes_test.plim: -------------------------------------------------------------------------------- 1 | a title="quick unicode string in 中文" 2 | input (placeholder=(u"選擇")) 3 | -------------------------------------------------------------------------------- /tests/fixtures/unicode_attributes_result.mako: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/until_result.mako: -------------------------------------------------------------------------------- 1 | %while not (value): 2 | Test 3 | %endwhile 4 | 5 | %while not (value): 6 | Test 7 | %endwhile 8 | -------------------------------------------------------------------------------- /tests/fixtures/scss_result.mako: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/with_test.plim: -------------------------------------------------------------------------------- 1 | -with open("x.txt") as f 2 | div Test 3 | 4 | - with open("x.txt") as f 5 | div Test -------------------------------------------------------------------------------- /tests/cli_fixtures/custom_parser_template.plim: -------------------------------------------------------------------------------- 1 | / Regular comment, it is not rendered 2 | 3 | /!But this comment will be rendered as an html comment tag -------------------------------------------------------------------------------- /tests/fixtures/with_result.mako: -------------------------------------------------------------------------------- 1 | %with open("x.txt") as f: 2 |
Test
3 | %endwith 4 | 5 | %with open("x.txt") as f: 6 |
Test
7 | %endwith -------------------------------------------------------------------------------- /tests/fixtures/unless_result.mako: -------------------------------------------------------------------------------- 1 | %if not (value == 5): 2 | ${value} 3 | %endif 4 | 5 | %if not (value == 5): 6 | ${value} 7 | %else: 8 | ${value + 1} 9 | %endif -------------------------------------------------------------------------------- /docs/authors.rst: -------------------------------------------------------------------------------- 1 | Authors 2 | ======= 3 | 4 | .. include:: ../AUTHORS 5 | 6 | See also `a list of Slim authors `_. 7 | -------------------------------------------------------------------------------- /tests/fixtures/coffee_result.mako: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/unless_test.plim: -------------------------------------------------------------------------------- 1 | - unless value == 5 2 | =value 3 | 4 | -unless\ 5 | \ 6 | value\ 7 | ==\ 8 | 5 9 | =value 10 | -else 11 | = value + 1 -------------------------------------------------------------------------------- /tests/fixtures/handlebars_test.plim: -------------------------------------------------------------------------------- 1 | html 2 | body 3 | handlebars 4 | .container {{outlet}} 5 | 6 | handlebars#about: .container {{outlet}} 7 | -------------------------------------------------------------------------------- /tests/fixtures/linebreak_result.mako: -------------------------------------------------------------------------------- 1 |
-------------------------------------------------------------------------------- /tests/fixtures/linebreak_test.plim: -------------------------------------------------------------------------------- 1 | .extra-title 2 | input style="margin:0 10px 23px 0" type="text" name="extra_title" \ 3 | value=extra_title[0] maxlength=200 4 | -------------------------------------------------------------------------------- /tests/fixtures/comment_result.mako: -------------------------------------------------------------------------------- 1 |
Test 1
Test 2
-------------------------------------------------------------------------------- /tests/fixtures/dynamic_attributes_test.plim: -------------------------------------------------------------------------------- 1 | a**attrs|Test 2 | 3 | a **attrs,Test2 4 | 5 | a( 6 | **attrs( 7 | data=**{'a':'b'} 8 | ) 9 | ) Test3 10 | 11 | a(**attrs**attrs2 disabled) Test4 -------------------------------------------------------------------------------- /tests/fixtures/try_test.plim: -------------------------------------------------------------------------------- 1 | -try 2 | div Test 3 | - except IOError 4 | div IOError 5 | -except KeyError as e 6 | div = e 7 | - else 8 | div All was well 9 | -finally 10 | div Finally 11 | -------------------------------------------------------------------------------- /tests/fixtures/multiline_variable_result.mako: -------------------------------------------------------------------------------- 1 | ${form(fieldset('',field('text',title=_('Tab name'),name='name',size=30,maxlength=16,tip=_('Enter a tab name (up to 16 characters).'),required="required")),render_buttons=False)+ "Test"} -------------------------------------------------------------------------------- /tests/fixtures/stylus_result.mako: -------------------------------------------------------------------------------- 1 | 9 | -------------------------------------------------------------------------------- /tests/fixtures/handlebars_result.mako: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/scss_test.plim: -------------------------------------------------------------------------------- 1 | -scss 2 | @option style: expanded; 3 | .selector { 4 | a { 5 | display: block; 6 | } 7 | strong { 8 | color: blue; 9 | } 10 | } -------------------------------------------------------------------------------- /tests/fixtures/try_result.mako: -------------------------------------------------------------------------------- 1 | %try: 2 |
Test
3 | %except IOError: 4 |
IOError
5 | %except KeyError as e: 6 |
${e}
7 | %else: 8 |
All was well
9 | %finally: 10 |
Finally
11 | %endtry -------------------------------------------------------------------------------- /tests/fixtures/explicit_space_result.mako: -------------------------------------------------------------------------------- 1 |

${ungettext('The link remains valid for {num} day.','The link remains valid for {num} days.',3).format(num=3)} ${_('Upon the expiration of this period, all non-activated accounts ''will be removed from the site.')}

-------------------------------------------------------------------------------- /tests/fixtures/style_script_result.mako: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/call_test.plim: -------------------------------------------------------------------------------- 1 | -call expression="${4==4}" self:conditional 2 | |i'm the result 3 | 4 | - call expression=${4==4} self:conditional 5 | | i'm the result 6 | 7 | - call self:conditional 8 | | i'm the result 9 | 10 | - call self:conditional 11 | 12 | -------------------------------------------------------------------------------- /tests/fixtures/style_script_test.plim: -------------------------------------------------------------------------------- 1 | style type="text/css" 2 | h1 {color:red;} 3 | p {color:blue;} 4 | 5 | 6 | script type="text/javascript" 7 | document.write("Hello World!"); 8 | // test that `embedded markup` is not parsed 9 | document.write("`hello world`"); 10 | -------------------------------------------------------------------------------- /tests/fixtures/stylus_test.plim: -------------------------------------------------------------------------------- 1 | -stylus 2 | body 3 | background: linear-gradient(top, white, black) 4 | 5 | border-radius() 6 | -webkit-border-radius arguments 7 | -moz-border-radius arguments 8 | border-radius arguments 9 | 10 | a.button 11 | border-radius 5px 12 | -------------------------------------------------------------------------------- /docs/license.rst: -------------------------------------------------------------------------------- 1 | License 2 | ========= 3 | 4 | Plim source code is licensed under the `MIT license `_. 5 | 6 | Plim Documentation is licensed under the 7 | `Creative Commons Attribution-ShareAlike 3.0 Unported License `_. 8 | -------------------------------------------------------------------------------- /tests/fixtures/explicit_space_test.plim: -------------------------------------------------------------------------------- 1 | p 2 | =, ungettext('The link remains valid for {num} day.', 3 | 'The link remains valid for {num} days.', 4 | 3).format(num=3) 5 | = _('Upon the expiration of this period, all non-activated accounts ' 6 | 'will be removed from the site.') -------------------------------------------------------------------------------- /tests/fixtures/call_result.mako: -------------------------------------------------------------------------------- 1 | <%self:conditional expression="${4==4}"> 2 | i'm the result 3 | 4 | <%self:conditional expression="${4==4}"> 5 | i'm the result 6 | 7 | <%self:conditional> 8 | i'm the result 9 | 10 | <%self:conditional> 11 | -------------------------------------------------------------------------------- /tests/fixtures/pipe_result.mako: -------------------------------------------------------------------------------- 1 | # We are inside indented block 2 | Test 3 | Test # 6 4 | Test # 4 5 | Test # 3 6 | Test # 2 7 | Test # 1---------------------TestTestTest 8 | Test1 9 | Test2 10 | Test4Test 11 | # we are inside toplevel literal 12 | | Test---------------------# Pipe with explicit space 13 | Test -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Plim was created by `Maxim Avanov `_. 2 | 3 | 4 | Contributors (in chronological order of the first contribution) 5 | =============================================================== 6 | 7 | - Keith Yang - https://github.com/keitheis 8 | - iMom0 - https://github.com/imom0 9 | - dongweiming - https://github.com/dongweiming 10 | -------------------------------------------------------------------------------- /.coveragerc: -------------------------------------------------------------------------------- 1 | # Nosetests gather coverage for all executed code, ignoring source config option in .coveragerc. 2 | # It means, that coveralls will report unnecessary files, which is inconvenient. Here is a workaround 3 | # to specify a list of filename patterns, the files to leave out of reporting. 4 | [report] 5 | omit = 6 | */python?.?/* 7 | *.egg/* 8 | */site-packages/* 9 | tests/* 10 | -------------------------------------------------------------------------------- /tests/fixtures/inline_conditions_test.plim: -------------------------------------------------------------------------------- 1 | - if i > 7: li: a href=route_to(i)=i 2 | 3 | -if i > 7: -if i < 10: a href=route_to(i)=i 4 | -else 5 | No link 6 | 7 | h2.caption:-if is_editor :a href="#" Edit 8 | -elif(is_admin) : a href="#" Delete 9 | -elif is_guest 10 | No Caption 11 | - else : Caption 12 | 13 | h3:-if idea:Idea 14 | -elif is_day: Think about it 15 | -else 16 | Sleep 17 | Cool! -------------------------------------------------------------------------------- /nixpkgs/default.nix: -------------------------------------------------------------------------------- 1 | let 2 | 3 | common-src = builtins.fetchTarball { 4 | name = "common-2022-09-15"; 5 | url = https://github.com/avanov/nix-common/archive/6e47c05632c781e0279f4b4609fb4125e4e7bf67.tar.gz; 6 | # Hash obtained using `nix-prefetch-url --unpack ` 7 | sha256 = "sha256:1av8r2wn4nqwldkkmij4pig9x4nhii7x053i0bd1ngi66kxdkxhr"; 8 | }; 9 | 10 | in 11 | 12 | import common-src { projectOverlays = []; } 13 | -------------------------------------------------------------------------------- /tests/fixtures/comment_test.plim: -------------------------------------------------------------------------------- 1 | / This is a comment. 2 | You can comment-out entire block with indentation 3 | div Test 1 4 | / Another test 5 | / Yet another test 6 | / 7 | / 8 | / 9 | div Test 2 10 | / 11 | / 12 | ////////////////////////// 13 | div 14 | nav style='display:inline;margin-left:10px' 15 | / 16 | Let's test empty-line-after-comment behaviour 17 | 18 | ${_('Interface')}: 19 | span#more-languages 20 | -------------------------------------------------------------------------------- /tests/fixtures/multiline_variable_test.plim: -------------------------------------------------------------------------------- 1 | = form( 2 | fieldset('', 3 | field('text', 4 | title=_('Tab name'), 5 | name='name', 6 | size=30, 7 | maxlength=16, 8 | tip=_('Enter a tab name (up to 16 characters).'), 9 | required="required" 10 | ) 11 | ), 12 | render_buttons=False 13 | ) 14 | + "Test" 15 | 16 | -------------------------------------------------------------------------------- /tests/fixtures/mako_text_test.plim: -------------------------------------------------------------------------------- 1 | -text filter="h" 2 | here's some fake mako ${syntax} 3 | <%def name="x()">${x} 4 | 5 | - text filter="h" here's some fake mako ${syntax} 6 | <%def name="x()">${x} 7 | 8 | - text filter="h" = syntax 9 | <%def name="x()">${x} 10 | 11 | -text 12 | here's some fake mako ${syntax} 13 | <%def name="x()">${x} 14 | 15 | -text , here's some fake mako ${syntax} 16 | <%def name="x()">${x} 17 | -------------------------------------------------------------------------------- /tests/fixtures/while_result.mako: -------------------------------------------------------------------------------- 1 | %while i: 2 |
${i}
3 | %endwhile 4 |
2 Test
------------------------------------ 5 | 6 | 7 | %while i in var: 8 |
${i}
9 | %if i: 10 |
4 Test
11 | %endif 12 |
5 Test
13 | %while i: 14 |
${i}
15 | %if i: 16 |
4 Test
17 | %endif 18 |
5 Test
19 | %endwhile 20 | 21 | %endwhile 22 | 23 | %while i in []: 24 | 25 | %endwhile 26 | %while i in [1,2,3,4,5]: 27 | 28 | %endwhile -------------------------------------------------------------------------------- /tests/fixtures/for_result.mako: -------------------------------------------------------------------------------- 1 | %for i in [1,2,3,4,5]: 2 |
${i}
3 | %endfor 4 |
2 Test
------------------------------------ 5 | 6 | %for i in var: 7 |
${i}
8 | %if i: 9 |
4 Test
10 | %endif 11 |
5 Test
12 | %for i in var: 13 |
${i}
14 | %if i: 15 |
4 Test
16 | %endif 17 |
5 Test
18 | %endfor 19 | 20 | %endfor 21 | 22 | %for i in []: 23 | 24 | %endfor 25 | 26 | %for i in [1,2,3,4,5]: 27 | ${i} 28 | %endfor -------------------------------------------------------------------------------- /plim/unportable.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | 4 | 5 | PARSE_IMPLICIT_LITERAL_RE = re.compile( 6 | # Order matters 7 | u'(?P(?:' 8 | u'\$?\{|\(|\[|&.+;|[0-9]+|' 9 | u'(?:' 10 | u'[^\u0021-\u007E]' # not ASCII 33 - 126 11 | u'|' # or 12 | u'[A-Z]' # uppercase latin letters (ASCII 65 - 90) 13 | u')' # It is possible because TAG_RE can match only lowercase tag names 14 | u').*)\s*' 15 | ) 16 | -------------------------------------------------------------------------------- /tests/fixtures/while_test.plim: -------------------------------------------------------------------------------- 1 | 2 | 3 | - while i 4 | div = i 5 | div 2 Test 6 | 7 | |------------------------------------ 8 | 9 | -while i in var 10 | div = i 11 | - if i 12 | div 4 Test 13 | div 5 Test 14 | -while i 15 | div = i 16 | - if i 17 | div 4 Test 18 | div 5 Test 19 | 20 | 21 | -while i in [] 22 | 23 | - while i in [ 24 | 1, 25 | 2, 26 | 3, 27 | 4 28 | ,5 29 | ] -------------------------------------------------------------------------------- /tests/fixtures/for_test.plim: -------------------------------------------------------------------------------- 1 | 2 | 3 | - for i in [1,2,3,4,5] 4 | div = i 5 | div 2 Test 6 | 7 | |------------------------------------ 8 | 9 | -for i in var 10 | div = i 11 | - if i 12 | div 4 Test 13 | div 5 Test 14 | -for i in var 15 | div = i 16 | - if i 17 | div 4 Test 18 | div 5 Test 19 | 20 | 21 | -for i in [] 22 | 23 | 24 | -for\ 25 | i\ 26 | \ 27 | in \ 28 | [1,2,3, 29 | 4,5] 30 | = i 31 | 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .[oa] 2 | *~ 3 | .py[co] 4 | .doit.db 5 | .idea/ 6 | 7 | build/ 8 | dist/ 9 | *.egg-info/ 10 | *.eggs/ 11 | *.local/ 12 | __pycache__/ 13 | # npm package lock, we don't need it as the 'stylus' dependency is optional 14 | package-lock.json 15 | 16 | docs/_build 17 | 18 | # Ignore all test-related files (see setup.py -> setup(tests_require=[])) 19 | *coverage* 20 | # but keep the .coveragerc (for TravisCI/Coveralls services) 21 | !.coveragerc 22 | *nose* 23 | *node_modules* 24 | *.mo 25 | *.doctree 26 | docs/locale/.doctrees/* 27 | -------------------------------------------------------------------------------- /tests/fixtures/mako_text_result.mako: -------------------------------------------------------------------------------- 1 | <%text filter="h"> 2 | here's some fake mako ${syntax} 3 | <%def name="x()">${x} 4 | 5 | 6 | <%text filter="h"> 7 | here's some fake mako ${syntax} 8 | <%def name="x()">${x} 9 | 10 | 11 | <%text filter="h"> 12 | ${syntax} 13 | <%def name="x()">${x} 14 | 15 | 16 | <%text> 17 | here's some fake mako ${syntax} 18 | <%def name="x()">${x} 19 | 20 | 21 | <%text> 22 | here's some fake mako ${syntax} 23 | <%def name="x()">${x} 24 | 25 | -------------------------------------------------------------------------------- /tests/cli_fixtures/custom_parser_module.py: -------------------------------------------------------------------------------- 1 | import re 2 | from plim import preprocessor_factory 3 | from plim.util import joined 4 | 5 | PARSE_DISPLAY_COMMENT_RE = re.compile('/!.*') 6 | 7 | def parse_can_display_comment(indent_level, current_line, matched, source, syntax): 8 | return joined(['']), indent_level, '', source 9 | 10 | CUSTOM_PARSERS = [ 11 | (PARSE_DISPLAY_COMMENT_RE, parse_can_display_comment) 12 | ] 13 | 14 | custom_preprocessor = preprocessor_factory(custom_parsers=CUSTOM_PARSERS, syntax='mako') 15 | -------------------------------------------------------------------------------- /tests/fixtures/inline_conditions_result.mako: -------------------------------------------------------------------------------- 1 | %if i > 7: 2 |
  • ${i}
  • 3 | %endif 4 | %if i > 7: 5 | %if i < 10: 6 | ${i} 7 | %else: 8 | No link 9 | %endif 10 | %endif 11 |

    12 | %if is_editor: 13 | Edit 14 | %elif (is_admin): 15 | Delete 16 | %elif is_guest: 17 | No Caption 18 | %else: 19 | Caption 20 | %endif 21 |

    22 | %if idea: 23 | Idea 24 | %elif is_day: 25 | Think about it 26 | %else: 27 | Sleep 28 | %endif 29 |

    Cool! 30 | -------------------------------------------------------------------------------- /plim/util.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from typing import Sequence, Iterable 3 | 4 | PY3K = sys.version_info >= (3, 0) 5 | 6 | from io import StringIO 7 | 8 | 9 | def joined(buf: Iterable[str], sep: str = '') -> str: 10 | """ note: `buf` iterable will be fully consumed, so if you are passing a stream make sure you tee it 11 | if you need to use the `buf` again later 12 | """ 13 | return sep.join(buf) 14 | 15 | 16 | def space_separated(buf: Sequence[str]) -> str: 17 | return joined(buf, ' ') 18 | 19 | 20 | u = str 21 | MAXSIZE = sys.maxsize 22 | -------------------------------------------------------------------------------- /tests/fixtures/for_result.dtl: -------------------------------------------------------------------------------- 1 | {% for i in [1,2,3,4,5] %} 2 |
    {{i}}
    3 | {% endfor %} 4 |
    2 Test
    ------------------------------------ 5 | 6 | {% for i in var %} 7 |
    {{i}}
    8 | {% if i %} 9 |
    4 Test
    10 | {% endif %} 11 |
    5 Test
    12 | {% for i in var %} 13 |
    {{i}}
    14 | {% if i %} 15 |
    4 Test
    16 | {% endif %} 17 |
    5 Test
    18 | {% endfor %} 19 | 20 | {% endfor %} 21 | 22 | {% for i in [] %} 23 | 24 | {% endfor %} 25 | 26 | {% for i in [1,2,3,4,5] %} 27 | {{i}} 28 | {% endfor %} -------------------------------------------------------------------------------- /tests/fixtures/pipe_test.plim: -------------------------------------------------------------------------------- 1 | | # We are inside indented block 2 | 3 | Test 4 | Test # 6 5 | Test # 4 6 | Test # 3 7 | Test # 2 8 | Test # 1 9 | 10 | |--------------------- 11 | 12 | | Test 13 | | Test 14 | 15 | | Test 16 | Test1 17 | Test2 18 | Test4 19 | 20 | | 21 | Test 22 | # we are inside toplevel literal 23 | | Test 24 | 25 | |--------------------- 26 | ,# Pipe with explicit space 27 | Test -------------------------------------------------------------------------------- /tests/fixtures/inline_loop_test.plim: -------------------------------------------------------------------------------- 1 | -for item in ['a','b','c',':'][::][1:]: li: strong = Case1 2 | 3 | -for item in ['a','b','c',':'][::][1:]: li 4 | strong = Case2 5 | 6 | -for item in ['a','b','c',':'][::][1:]: li: -for item2 in ['a','b','c',':'][::][1:] 7 | strong = Case3 8 | 9 | 10 | ul: -for item in {1, 2, 3}: li.link:a(href=route_to(item))=item 11 | 12 | ul: -for link in [ 13 | 'About', 14 | 'Blog', 15 | 'Sitemap' 16 | ]: li: a href=route_to(link) = link 17 | 18 | table: -for item in items: tr 19 | td = item.name 20 | td = item.price 21 | -------------------------------------------------------------------------------- /tests/fixtures/embedded_result.mako: -------------------------------------------------------------------------------- 1 | Embedded string everywhere 2 | --- 3 | Embedded strings everywhere 4 | --- 5 | This is a link embedded
    into a literal block. 6 | --- 7 | another very funny recursive test 8 | --- 9 | Embed everything
    statements 10 | %for word in ['like', 'this']: 11 | ${word} 12 | %endfor 13 |
    . 14 | --- 15 | Try using multi-line embedded markup Like this test 16 | -------------------------------------------------------------------------------- /tests/fixtures/one_liners_result.mako: -------------------------------------------------------------------------------- 1 | <%inherit file="base.html"/><%inherit file="base.html"/><%inherit/><%inherit file="/ideas/base.html"/><%page args="x, y, z='default'"/><%page/><%include file="header.html"/>Content<%include file="footer.html"/><%namespace name="dyn" file="${context['namespace_name']}"/><%namespace file="${context['namespace_name']}" name="dyn"/><%namespace file="${context['namespace_name']}" name="dyn"/><%namespace file="${context['namespace_name']}" name="dyn"/><%namespace file="${context['namespace_name']} " name="dyn"/><%namespace file="${context['namespace_name']} " name="dyn"/> -------------------------------------------------------------------------------- /tests/fixtures/one_liners_test.plim: -------------------------------------------------------------------------------- 1 | -inherit base.html 2 | - inherit file="base.html" 3 | -inherit 4 | -inherit /ideas/base.html 5 | 6 | -page args="x, y, z='default'" 7 | - page 8 | 9 | -include file="header.html" 10 | | Content 11 | - include footer.html 12 | 13 | -namespace name="dyn" file="${context['namespace_name']}" 14 | - namespace name="dyn" = context['namespace_name'] 15 | -namespace name="dyn" ${context['namespace_name']} 16 | -namespace name="dyn" | ${context['namespace_name']} 17 | -namespace name="dyn" , ${context['namespace_name']} 18 | -namespace name="dyn" =, context['namespace_name'] -------------------------------------------------------------------------------- /tests/django_test/fixtures/if_test.plim: -------------------------------------------------------------------------------- 1 | 2 | 3 | - if True 4 | div 1 Test 5 | div 2 Test 6 | 7 | |------------------------------------ 8 | 9 | -if False 10 | div 3 False Test 11 | - if True 12 | div 4 Test 13 | div 5 Test 14 | -elif True 15 | div 6 True Test 16 | - elif 1 == 1 17 | div 7 Test 18 | -else 19 | div 8 Else Test 20 | 21 | -if False 22 | -elif True 23 | -else 24 | 25 | /-------------------------------- 26 | - if ( 27 | a == b 28 | ) or ( 29 | c == d) 30 | |Test 31 | -elif ( 32 | e == f 33 | ) 34 | |Test2 -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [mypy] 2 | warn_unused_ignores = true 3 | follow_imports = normal 4 | show_error_context = true 5 | warn_incomplete_stub = true 6 | ignore_missing_imports = true 7 | check_untyped_defs = true 8 | cache_dir = ./.local/mypy-cache 9 | warn_redundant_casts = true 10 | warn_unused_configs = true 11 | strict_optional = true 12 | strict_equality = true 13 | 14 | [coverage:report] 15 | # Regexes for lines to exclude from consideration 16 | exclude_lines = 17 | # Have to re-enable the standard pragma 18 | pragma: no cover 19 | 20 | ignore_errors = True 21 | 22 | [coverage:run] 23 | source = 24 | plim 25 | -------------------------------------------------------------------------------- /docs/related.rst: -------------------------------------------------------------------------------- 1 | Related projects 2 | ================ 3 | 4 | There is a number of similar projects that you might be interested in. 5 | 6 | - `slimish-jinja2 `_ 7 | - `PyJade `_ 8 | - `mint `_ 9 | - `SHPAML `_ 10 | - `Yammy `_ 11 | - `PyHAML `_ 12 | - `HamlPy `_ 13 | 14 | See also `a list of Slim related projects `_. -------------------------------------------------------------------------------- /tests/fixtures/if_result.mako: -------------------------------------------------------------------------------- 1 | %if True: 2 |
    1 Test
    3 | %endif 4 |
    2 Test
    ------------------------------------ 5 | 6 | %if False: 7 |
    3 False Test
    8 | %if True: 9 |
    4 Test
    10 | %endif 11 |
    5 Test
    12 | %elif True: 13 |
    6 True Test
    14 | %elif 1 == 1: 15 |
    7 Test
    16 | %else: 17 |
    8 Else Test
    18 | %endif 19 | 20 | %if False: 21 | 22 | %elif True: 23 | 24 | %else: 25 | 26 | %endif 27 | %if (a == b) or (c == d): 28 | Test 29 | %elif (e == f): 30 | Test2 31 | %endif 32 | %if "permission:admin" in effective_principals(request): 33 |

    Allow

    34 | %endif -------------------------------------------------------------------------------- /tests/fixtures/embedded_test.plim: -------------------------------------------------------------------------------- 1 | a href="#" Embedded `strong string` everywhere 2 | 3 | a href="#" Embedded `strong string`_`i s` everywhere 4 | 5 | This is a `a href="#" link` embedded `br` into a literal block. 6 | 7 | | another `a href="#" very ``strong funny ````i recursive``````` test 8 | 9 | Embed everything `#even statements``-for word in ['like', 'this']:= word```. 10 | 11 | Try using multi-line embedded markup `a( 12 | href="#" 13 | ): Like this ``strong( 14 | data-something="true" 15 | ) test``` 16 | -------------------------------------------------------------------------------- /tests/fixtures/plim_multiline_tag_result.mako: -------------------------------------------------------------------------------- 1 |
    Test
    2 |
    ${Test()}
    3 | ${title} 4 |
    5 |

    ${_(u'Editing "{title}" information').format(title=c.title)}

    6 |
    ${url('product',tagname=tagname)}
    7 | ${Test} 8 | ${Test} 9 |
    -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: https://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | # Unix-style newlines with a newline ending every file 7 | [*] 8 | end_of_line = lf 9 | insert_final_newline = true 10 | 11 | # Matches multiple files with brace expansion notation 12 | # Set default charset 13 | [*.{js,py}] 14 | charset = utf-8 15 | 16 | # 4 space indentation 17 | [*.py] 18 | indent_style = space 19 | indent_size = 4 20 | 21 | [*.sh] 22 | indent_style = space 23 | indent_size = 4 24 | 25 | # Tab indentation (no size specified) 26 | [Makefile] 27 | indent_style = tab 28 | 29 | [*.nix] 30 | indent_style = space 31 | indent_size = 4 32 | -------------------------------------------------------------------------------- /tests/fixtures/if_test.plim: -------------------------------------------------------------------------------- 1 | 2 | 3 | - if True 4 | div 1 Test 5 | div 2 Test 6 | 7 | |------------------------------------ 8 | 9 | -if False 10 | div 3 False Test 11 | - if True 12 | div 4 Test 13 | div 5 Test 14 | -elif True 15 | div 6 True Test 16 | - elif 1 == 1 17 | div 7 Test 18 | -else 19 | div 8 Else Test 20 | 21 | -if False 22 | -elif True 23 | -else 24 | 25 | /-------------------------------- 26 | - if ( 27 | a == b 28 | ) or ( 29 | c == d) 30 | |Test 31 | -elif ( 32 | e == f 33 | ) 34 | |Test2 35 | 36 | -if "permission:admin" in effective_principals(request) 37 | p Allow 38 | -------------------------------------------------------------------------------- /tests/fixtures/dynamic_attributes_result.mako: -------------------------------------------------------------------------------- 1 | TestTest2 Test3Test4 22 | -------------------------------------------------------------------------------- /tests/fixtures/if_result.dtl: -------------------------------------------------------------------------------- 1 | {% if True %} 2 |
    1 Test
    3 | {% endif %} 4 |
    2 Test
    ------------------------------------ 5 | 6 | {% if False %} 7 |
    3 False Test
    8 | {% if True %} 9 |
    4 Test
    10 | {% endif %} 11 |
    5 Test
    12 | {% elif True %} 13 |
    6 True Test
    14 | {% elif 1 == 1 %} 15 |
    7 Test
    16 | {% else %} 17 |
    8 Else Test
    18 | {% endif %} 19 | 20 | {% if False %} 21 | 22 | {% elif True %} 23 | 24 | {% else %} 25 | 26 | {% endif %} 27 | {% if (a == b) or (c == d) %} 28 | Test 29 | {% elif (e == f) %} 30 | Test2 31 | {% endif %} 32 | {% if "permission:admin" in effective_principals(request) %} 33 |

    Allow

    34 | {% endif %} -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | Mako>=0.9.0 2 | pyrsistent>=0.18.1 3 | babel>=1.3 4 | # We use reStructuredText (docutils component) for both supporting 5 | # the "-rest" extension and project documenting. So, ensure that the docutils 6 | # get installed or upgraded on the target machine 7 | docutils>=0.3 8 | # We use Markdown for the "-markdown" extension 9 | markdown2>=1.4.2 10 | # Explicitly list PyExecJs as a dependency for the CoffeeScript and Stylus extensions 11 | PyExecJS>=1.0.4 12 | # We use CoffeeScript for "-coffee" extension 13 | CoffeeScript 14 | # We use SCSS for "-scss/sass" extension 15 | pyScss>=1.2.0.post3 16 | # We use the stylus package for "-stylus" extension 17 | # https://github.com/bkad/python-stylus 18 | stylus>=0.1.1 19 | -------------------------------------------------------------------------------- /docs/locale/zh_CN/LC_MESSAGES/cli.po: -------------------------------------------------------------------------------- 1 | # 2 | msgid "" 3 | msgstr "" 4 | "Project-Id-Version: Plim 0.9\n" 5 | "Report-Msgid-Bugs-To: \n" 6 | "POT-Creation-Date: 2015-06-12 16:42+0800\n" 7 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 8 | "Last-Translator: FULL NAME \n" 9 | "Language-Team: LANGUAGE \n" 10 | "MIME-Version: 1.0\n" 11 | "Content-Type: text/plain; charset=UTF-8\n" 12 | "Content-Transfer-Encoding: 8bit\n" 13 | 14 | #: ../cli.rst:2 15 | msgid "Command-line Interface" 16 | msgstr "命令行接口" 17 | 18 | #: ../cli.rst:6 19 | msgid "" 20 | "The package provides the command-line tool ``plimc`` to compile plim source " 21 | "files into Mako templates." 22 | msgstr "Plim 提供命令行工具 ``plimc`` 用于将 plim 源文件转换为 mako 模板。" 23 | -------------------------------------------------------------------------------- /plim/errors.py: -------------------------------------------------------------------------------- 1 | class PlimError(Exception): 2 | pass 3 | 4 | 5 | class PlimSyntaxError(PlimError): 6 | def __init__(self, msg: str, line: str): 7 | super(PlimSyntaxError, self).__init__() 8 | self.msg = msg 9 | self.line = line 10 | 11 | def __str__(self) -> str: 12 | return '{msg} | at line(pos) "{line}"'.format(msg=self.msg, line=self.line) 13 | 14 | 15 | class ParserNotFound(PlimError): 16 | def __init__(self, lineno: int, line: str): 17 | super(ParserNotFound, self).__init__() 18 | self.lineno = lineno 19 | self.line = line 20 | 21 | def __str__(self) -> str: 22 | return "Invalid syntax at line {lineno}: {line}".format( 23 | lineno=self.lineno, line=self.line) 24 | -------------------------------------------------------------------------------- /tests/fixtures/inline_loop_result.mako: -------------------------------------------------------------------------------- 1 | %for item in ['a','b','c',':'][::][1:]: 2 |
  • ${Case1}
  • 3 | %endfor 4 | 5 | %for item in ['a','b','c',':'][::][1:]: 6 |
  • ${Case2}
  • 7 | %endfor 8 | 9 | %for item in ['a','b','c',':'][::][1:]: 10 |
  • 11 | %for item2 in ['a','b','c',':'][::][1:]: 12 | ${Case3} 13 | %endfor 14 |
  • 15 | %endfor 16 |
      17 | %for item in {1, 2, 3}: 18 | 19 | %endfor 20 |
      21 | %for link in ['About','Blog','Sitemap']: 22 |
    • ${link}
    • 23 | %endfor 24 |
    25 | %for item in items: 26 | 27 | %endfor 28 |
    ${item.name}${item.price}
    29 | -------------------------------------------------------------------------------- /tests/fixtures/def_block_result.mako: -------------------------------------------------------------------------------- 1 | <%def name="hello()"> 2 | hello world 3 | <%def name="account()"> 4 | Account for ${username}:
    5 | %for row in accountdata: 6 | Value: ${row}
    7 | %endfor 8 | 9 | <%def name="account(accountname, type=u'中文')"> 10 | account name: ${accountname}, type: ${type} 11 | <%def name="mydef()"> 12 | <%def name="subdef()"> 13 | a sub def 14 | i'm the def, and the subcomponent is ${subdef()} 15 | <%block> 16 | this is a block. 17 | <%block filter="h"> 18 | this is some escaped html. 19 | <%block name="post_prose" args="post"> 20 | ${post.content} 21 | <%block name="post_prose"> 22 | ${pageargs['post'].content} 23 | <%block name="post_prose"> 24 | ${pageargs['post'].content} -------------------------------------------------------------------------------- /tests/fixtures/def_block_test.plim: -------------------------------------------------------------------------------- 1 | - def hello() 2 | | hello world 3 | 4 | 5 | - def account() 6 | | Account for ${username}:
    7 | 8 | - for row in accountdata 9 | | Value: ${row}
    10 | 11 | 12 | -def account(accountname, type=u'中文') 13 | | account name: ${accountname}, type: ${type} 14 | 15 | 16 | -def mydef() 17 | -def subdef() 18 | | a sub def 19 | 20 | | i'm the def, and the subcomponent is ${subdef()} 21 | 22 | 23 | html:body 24 | -block 25 | | this is a block. 26 | 27 | 28 | - block filter="h" 29 | html this is some escaped html. 30 | 31 | 32 | span.post_prose 33 | -block args="post" post_prose 34 | = post.content 35 | 36 | -block name="post_prose" 37 | =pageargs['post'].content 38 | 39 | -block post_prose 40 | = pageargs['post'].content 41 | -------------------------------------------------------------------------------- /docs/locale/cli.pot: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) 2014, Maxim Avanov 3 | # This file is distributed under the same license as the Plim package. 4 | # FIRST AUTHOR , YEAR. 5 | # 6 | #, fuzzy 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: Plim 0.9\n" 10 | "Report-Msgid-Bugs-To: \n" 11 | "POT-Creation-Date: 2015-06-22 20:43+0800\n" 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 13 | "Last-Translator: FULL NAME \n" 14 | "Language-Team: LANGUAGE \n" 15 | "MIME-Version: 1.0\n" 16 | "Content-Type: text/plain; charset=UTF-8\n" 17 | "Content-Transfer-Encoding: 8bit\n" 18 | 19 | #: ../cli.rst:2 20 | # 8c06214bc2904c77ae8c964023a37229 21 | msgid "Command-line Interface" 22 | msgstr "" 23 | 24 | #: ../cli.rst:6 25 | # fc0a1982d2ce4a5f9027483588769b1b 26 | msgid "The package provides the command-line tool ``plimc`` to compile plim source files into Mako templates." 27 | msgstr "" 28 | 29 | -------------------------------------------------------------------------------- /plim/extensions.py: -------------------------------------------------------------------------------- 1 | from typing import Mapping 2 | 3 | from docutils.core import publish_parts 4 | import coffeescript 5 | from scss import Scss 6 | from stylus import Stylus 7 | 8 | 9 | 10 | def rst_to_html(source: str) -> str: 11 | # This code was taken from http://wiki.python.org/moin/ReStructuredText 12 | # You may also be interested in http://www.tele3.cz/jbar/rest/about.html 13 | html: Mapping[str, str] = publish_parts(source=source, writer_name='html') 14 | return html['html_body'] 15 | 16 | 17 | def coffee_to_js(source: str) -> str: 18 | return ''.format(js=coffeescript.compile(source)) 19 | 20 | 21 | def scss_to_css(source: str) -> str: 22 | css = Scss().compile(source).strip() 23 | return ''.format(css=css) 24 | 25 | 26 | def stylus_to_css(source: str) -> str: 27 | compiler = Stylus() 28 | return ''.format(css=compiler.compile(source).strip()) 29 | -------------------------------------------------------------------------------- /tests/fixtures/plim_multiline_tag_test.plim: -------------------------------------------------------------------------------- 1 | div ( 2 | 3 | title="value)" 4 | 5 | ) Test 6 | 7 | 8 | #idx(title=value("value()") 9 | ) = Test() 10 | 11 | a.title( 12 | href=( 13 | url( 14 | 'product', 15 | tagname=tagname 16 | ) 17 | ) 18 | ) = title 19 | 20 | #m${ 21 | c.message.id 22 | }.msg${ 23 | ( 24 | "test" 25 | ) 26 | } 27 | 28 | h2 = _(u'Editing "{title}" information').format( 29 | title=c.title) 30 | 31 | div =, url( 32 | 'product', 33 | tagname=tagname 34 | ) 35 | 36 | 37 | img\ 38 | title="Title" \ you can leave 39 | src="image.png"\ one-line 40 | \comments 41 | \ after 42 | width="100"\ linebreak 43 | = Test 44 | 45 | img\ 46 | ( 47 | title="Title" \ 48 | src="image.png"\ 49 | \ 50 | \ 51 | width="100"\ 52 | ) = Test 53 | 54 | 55 | #m${c.message.id}.msg class=( 56 | ((prev_author != c.message.author or prev_day != c.message.time.day) and ' with-border' or '') 57 | ) 58 | -------------------------------------------------------------------------------- /tests/fixtures/plim_line_result.mako: -------------------------------------------------------------------------------- 1 | Title
    ${_('Founded in')} ${year}.
    Test1
    Test2
    Test3
    Test4
    Test5

    ${Test|n}

    3 | 4 | -------------------------------------------------------------------------------- /tests/fixtures/python_result.mako: -------------------------------------------------------------------------------- 1 | <% 2 | x = 1 3 | y = x + 1 4 | if True: 5 | y += 1 6 | else: 7 | y -= 1 8 | %> 9 | <% 10 | z = y + 1 11 | %> 12 | <% 13 | a = z + y + x 14 | %> 15 | <%! 16 | from abcde import fghi 17 | from module import func 18 | %> 19 | <% 20 | a = u'Привет Мир!' 21 | %> 22 | <% 23 | 24 | for i in i_list: 25 | for j in j_list: 26 | print i, j 27 | if i == j: 28 | print "Equal" 29 | if True: 30 | print "True" 31 | %> 32 | <% 33 | # Test that `embedded markup` is not parsed 34 | a = "`test test`" 35 | %> 36 | <% 37 | text = 'new-style python blocks' 38 | %> 39 |
    <% 40 | count = 10 41 | for i in range(count): 42 | print i 43 | %> 44 |
    <% 45 | count = 0 46 | count += 1 47 | %> 48 |
    <% 49 | under_the_line = True 50 | %> 51 |
    <% 52 | count = 1 53 | for i in range(count): 54 | print i 55 | %> 56 | <% 57 | # Inline feature is primarily for placing comments as here 58 | var = 1 59 | %> 60 | <%! 61 | from datetime import datetime 62 | %> 63 | <%! 64 | from json import dumps 65 | %> 66 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # https://www.gnu.org/software/make/manual/html_node/Special-Variables.html 2 | # https://ftp.gnu.org/old-gnu/Manuals/make-3.80/html_node/make_17.html 3 | PROJECT_MKFILE_PATH := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) 4 | PROJECT_MKFILE_DIR := $(shell cd $(shell dirname $(PROJECT_MKFILE_PATH)); pwd) 5 | 6 | PROJECT_NAME := plim 7 | PROJECT_ROOT := $(PROJECT_MKFILE_DIR) 8 | 9 | BUILD_DIR := $(PROJECT_ROOT)/build 10 | DIST_DIR := $(PROJECT_ROOT)/dist 11 | 12 | PROJECT=plim 13 | 14 | .PHONY: test 15 | test: 16 | pytest -s --cov=plim --cov-report xml $(PROJECT_ROOT)/tests 17 | 18 | .PHONY: typecheck 19 | typecheck: 20 | mypy --config-file setup.cfg --strict --package $(PROJECT_NAME) 21 | 22 | .PHONY: prepare-dist 23 | prepare-dist: 24 | rm -rf $(BUILD_DIR) $(DIST_DIR) 25 | python $(PROJECT_ROOT)/setup.py sdist bdist_wheel 26 | 27 | .PHONY: publish 28 | publish: | test publish 29 | twine upload $(DIST_DIR)/* 30 | 31 | .PHONY: shell 32 | shell: 33 | nix-shell $(PROJECT_ROOT)/shell.nix 34 | -------------------------------------------------------------------------------- /tests/django_test/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import os 3 | 4 | import plim 5 | from plim import lexer as l 6 | from plim import syntax 7 | from plim.errors import PlimSyntaxError, ParserNotFound 8 | from .. import TestCaseBase 9 | 10 | 11 | class TestDjangoSyntax(TestCaseBase): 12 | 13 | def setUp(self): 14 | super(TestDjangoSyntax, self).setUp() 15 | self.preprocessor = plim.preprocessor_factory(syntax='django') 16 | 17 | def test_conditionals(self): 18 | test_case = 'if' 19 | source = self.get_file_contents(test_case + '_test.plim') 20 | result = self.get_file_contents(test_case + '_result.dtl') 21 | data = self.preprocessor(source) 22 | self.check_relevant_chars(data.strip(), result.strip()) 23 | 24 | def test_loops(self): 25 | test_case = 'for' 26 | source = self.get_file_contents(test_case + '_test.plim') 27 | result = self.get_file_contents(test_case + '_result.dtl') 28 | data = self.preprocessor(source) 29 | self.check_relevant_chars(data.strip(), result.strip()) -------------------------------------------------------------------------------- /docs/cli.rst: -------------------------------------------------------------------------------- 1 | Command-line Interface 2 | ====================== 3 | 4 | .. versionadded:: 0.7.12 5 | 6 | The package provides the command-line tool ``plimc`` to compile plim 7 | source files into Mako templates. 8 | 9 | .. code-block:: shell 10 | 11 | $ plimc -h 12 | usage: plimc [-h] [-o OUTPUT] [-e ENCODING] [-p PREPROCESSOR] [-H] [-V] source 13 | 14 | Compile plim source files into mako files. 15 | 16 | positional arguments: 17 | source path to source plim template 18 | 19 | optional arguments: 20 | -h, --help show this help message and exit 21 | -o OUTPUT, --output OUTPUT 22 | write result to FILE. 23 | -e ENCODING, --encoding ENCODING 24 | content encoding 25 | -p PREPROCESSOR, --preprocessor PREPROCESSOR 26 | Preprocessor instance that will be used for parsing 27 | the template 28 | -H, --html Render HTML output instead of Mako template 29 | -V, --version show program's version number and exit 30 | 31 | -------------------------------------------------------------------------------- /pytest.ini: -------------------------------------------------------------------------------- 1 | # Can also be defined in setup.cfg or tox.ini files, but 2 | # searching stops when the first [pytest] section is found in any of these files. 3 | # There is no merging of configuration values from multiple files. 4 | # Read more on https://pytest.org/latest/customize.html 5 | # ------------------------------------------------------------------------------- 6 | [pytest] 7 | # This would tell py.test to not recurse into typical sphinx-build directories or 8 | # into any tmp prefixed directory. 9 | #https://docs.pytest.org/en/latest/reference.html#confval-norecursedirs 10 | norecursedirs = _build build dist tmp* *.egg* frontend* docs* deploy* 11 | 12 | # One or more Glob-style file patterns determining which python files are considered 13 | # as test modules. 14 | python_files = test_*.py *_test.py *_tests.py *_t.py 15 | 16 | # https://docs.pytest.org/en/latest/reference.html#confval-python_classes 17 | python_classes = 18 | Test* 19 | *Tests 20 | 21 | # https://docs.pytest.org/en/latest/reference.html#confval-testpaths 22 | testpaths = 23 | tests 24 | 25 | # use coverage plugin 26 | addopts = -s 27 | -------------------------------------------------------------------------------- /docs/locale/zh_CN/LC_MESSAGES/license.po: -------------------------------------------------------------------------------- 1 | # 2 | msgid "" 3 | msgstr "" 4 | "Project-Id-Version: Plim 0.9\n" 5 | "Report-Msgid-Bugs-To: \n" 6 | "POT-Creation-Date: 2015-06-12 16:42+0800\n" 7 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 8 | "Last-Translator: FULL NAME \n" 9 | "Language-Team: LANGUAGE \n" 10 | "MIME-Version: 1.0\n" 11 | "Content-Type: text/plain; charset=UTF-8\n" 12 | "Content-Transfer-Encoding: 8bit\n" 13 | 14 | #: ../license.rst:2 15 | msgid "License" 16 | msgstr "许可" 17 | 18 | #: ../license.rst:4 19 | msgid "" 20 | "Plim source code is licensed under the `MIT license " 21 | "`_." 22 | msgstr "" 23 | "Plim 源代码遵循 `MIT 协议 " 24 | "`_ 开源。" 25 | 26 | #: ../license.rst:6 27 | msgid "" 28 | "Plim Documentation is licensed under the `Creative Commons Attribution-" 29 | "ShareAlike 3.0 Unported License `_." 31 | msgstr "" 32 | "Plim 文档遵循 `创作共享 署名-相同方式分享 3.0 " 33 | "Unported License `_ 。" 35 | -------------------------------------------------------------------------------- /docs/locale/license.pot: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) 2014, Maxim Avanov 3 | # This file is distributed under the same license as the Plim package. 4 | # FIRST AUTHOR , YEAR. 5 | # 6 | #, fuzzy 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: Plim 0.9\n" 10 | "Report-Msgid-Bugs-To: \n" 11 | "POT-Creation-Date: 2015-06-22 20:43+0800\n" 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 13 | "Last-Translator: FULL NAME \n" 14 | "Language-Team: LANGUAGE \n" 15 | "MIME-Version: 1.0\n" 16 | "Content-Type: text/plain; charset=UTF-8\n" 17 | "Content-Transfer-Encoding: 8bit\n" 18 | 19 | #: ../license.rst:2 20 | # 8ec01d8b8aa649289b9730a1d2b05a08 21 | msgid "License" 22 | msgstr "" 23 | 24 | #: ../license.rst:4 25 | # 3d0ee7c864984ecf918d4bdc45a3f93a 26 | msgid "Plim source code is licensed under the `MIT license `_." 27 | msgstr "" 28 | 29 | #: ../license.rst:6 30 | # c98eb881a09c4644b7aec2b414b0f598 31 | msgid "Plim Documentation is licensed under the `Creative Commons Attribution-ShareAlike 3.0 Unported License `_." 32 | msgstr "" 33 | 34 | -------------------------------------------------------------------------------- /tests/adapters/test_babelplugin.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | from plim.adapters.babelplugin import extract 4 | from plim.util import StringIO 5 | from .. import TestCaseBase 6 | 7 | 8 | 9 | class TestBabelPlugin(TestCaseBase): 10 | 11 | def test_babel_extractor(self): 12 | fileobj = StringIO(self.get_file_contents('babelplugin_test.plim')) 13 | keywords = ['_', 'gettext', 'ungettext', 'pluralize'] 14 | extracted = [(data[1], data[2]) for data in extract(fileobj, keywords, [], {})] 15 | 16 | assert ('_', 'Test') in extracted 17 | assert ('_', 'View more') in extracted 18 | 19 | assert ('pluralize', ('${num} conversation has been marked as read.', 20 | '${num} conversations have been marked as read.', 21 | None, None)) in extracted 22 | assert ('ungettext', ('{num} conversation has been marked as read.', 23 | '{num} conversations have been marked as read.', 24 | None)) in extracted 25 | 26 | assert ('gettext', 'N') not in extracted 27 | 28 | 29 | -------------------------------------------------------------------------------- /plim/__init__.py: -------------------------------------------------------------------------------- 1 | import functools 2 | from typing import Mapping, Type, Sequence, Any, Callable 3 | 4 | from pyrsistent import v 5 | 6 | from .lexer import compile_plim_source 7 | from . import syntax as available_syntax 8 | 9 | 10 | def preprocessor_factory(custom_parsers: Sequence[Any] = v(), syntax: str = 'mako') -> Callable[[str, bool], str]: 11 | """ 12 | 13 | :param custom_parsers: a list of 2-tuples of (parser_regex, parser_callable) or None 14 | :type custom_parsers: list or None 15 | :param syntax: name of the target template engine ('mako' by default) 16 | :return: preprocessor instance 17 | """ 18 | syntax_choices: Mapping[str, Type[available_syntax.BaseSyntax]] = { 19 | 'mako': available_syntax.Mako, 20 | 'django': available_syntax.Django, 21 | } 22 | selected_syntax = syntax_choices[syntax](custom_parsers or v()) 23 | return functools.partial(compile_plim_source, syntax=selected_syntax) 24 | 25 | 26 | # ``preprocessor`` is a public object that always follows Mako's preprocessor API. 27 | # Do not use ``compile_plim_source`` in your projects, because its signature 28 | # may be changed in the future. 29 | preprocessor = preprocessor_factory() 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is the MIT license: http://www.opensource.org/licenses/mit-license.php 2 | 3 | Copyright (C) 2012 Maxim Avanov, see AUTHORS for more details. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this 6 | software and associated documentation files (the "Software"), to deal in the Software 7 | without restriction, including without limitation the rights to use, copy, modify, merge, 8 | publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 9 | to whom the Software is furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or 12 | substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 15 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 16 | PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 17 | FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 18 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | DEALINGS IN THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /tests/fixtures/plim_line_test.plim: -------------------------------------------------------------------------------- 1 | doctype 5 2 | html 3 | head 4 | title Title 5 | 6 | body 7 | div: a href=request.route_path('profile', tagname=tagname)=name 8 | .item.striped.${u' '.join([str(role) for role in roles])} 9 | .meta.founded ${_('Founded in')} ${year}. 10 | div Test1 11 | #test2 Test2 12 | #layout-960.decorated | Test3 13 | #test4.test4-1 Test4 14 | div , Test5 15 | p#${fully.dynamic}.${cls.attributes}.${cls.attributes.second}.third-${cls.third} = Test|n 16 | 17 | .block 18 | article 19 | table: tr 20 | td.pic: img src="/static/proto/upd/10.jpg" alt="" 21 | td.post 22 | h4: a href="#" Sony: No PlayStation Vita Shortages 23 | div style="float:left;" 24 | Sony has increased production of the Vita to make 25 | sure that there are plenty of systems to go around. 26 | .meta 27 | a href="#" 28 | img src="/static/interface/comment.png" width="16" 29 | span.txt 111 30 | -------------------------------------------------------------------------------- /tests/fixtures/babelplugin_test.plim: -------------------------------------------------------------------------------- 1 | -inherit ../_layouts/960.html 2 | -def test_def(test=_('Test')) 3 | = pluralize( 4 | '${num} conversation has been marked as read.', 5 | '${num} conversations have been marked as read.', 6 | msgs_num, mapping=dict(num=msgs_num)) 7 | = ungettext( 8 | '{num} conversation has been marked as read.', 9 | '{num} conversations have been marked as read.', 10 | msgs_num).format(num=msgs_num) 11 | 12 | #mosaic 13 | div style="float:none;clear:both" 14 | 15 | #latest-tabs 16 | div style="width:650px;background:#EFEFEF;padding:10px 0 10px 0" 17 | a.active href="#" = _('News') 18 | a href="#" = _('Articles') 19 | a href="#" = _('Videos') 20 | 21 | .more: a href="#" ${_('View more')} ▸ 22 | 23 | 24 | h2.block-title = _('Recent comments') 25 | #comments.block-ct 26 | .block-tabs 27 | a.active href="#" = _('News') 28 | a href="#" = _('Previews') 29 | a href="#" = _('Reviews') 30 | a href="#" = _('Videos') 31 | a href="#" = _('Blogs') 32 | 33 | .more: a href="#" ${_('View more')} ▸ 34 | 35 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | Plim 2 | ============== 3 | 4 | .. image:: https://img.shields.io/pypi/v/Plim.svg 5 | :target: https://crate.io/packages/Plim 6 | 7 | .. image:: https://requires.io/github/avanov/Plim/requirements.svg?branch=master 8 | :target: https://requires.io/github/avanov/Plim/requirements/?branch=master 9 | :alt: Requirements Status 10 | 11 | .. image:: https://img.shields.io/pypi/dm/Plim.svg 12 | :target: https://crate.io/packages/Plim 13 | 14 | .. image:: https://github.com/avanov/Plim/workflows/CI/badge.svg?branch=develop 15 | :target: https://github.com/avanov/Plim/actions?query=branch%3Adevelop 16 | 17 | .. image:: https://coveralls.io/repos/github/avanov/Plim/badge.svg?branch=develop 18 | :target: https://coveralls.io/github/avanov/Plim?branch=develop 19 | 20 | 21 | Plim is a Python port of `Ruby's Slim template language `_ 22 | built on top of `Mako Templates `_. 23 | It uses `Mako's preprocessor feature `_ 24 | to translate its syntax into a valid HTML/Mako markup. 25 | 26 | For more information visit the `Documentation Page`_. 27 | 28 | 29 | .. _Documentation Page: http://plim.readthedocs.org/en/latest/ 30 | -------------------------------------------------------------------------------- /docs/locale/zh_CN/LC_MESSAGES/authors.po: -------------------------------------------------------------------------------- 1 | # 2 | msgid "" 3 | msgstr "" 4 | "Project-Id-Version: Plim 0.9\n" 5 | "Report-Msgid-Bugs-To: \n" 6 | "POT-Creation-Date: 2015-06-12 16:42+0800\n" 7 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 8 | "Last-Translator: FULL NAME \n" 9 | "Language-Team: LANGUAGE \n" 10 | "MIME-Version: 1.0\n" 11 | "Content-Type: text/plain; charset=UTF-8\n" 12 | "Content-Transfer-Encoding: 8bit\n" 13 | 14 | #: ../authors.rst:2 15 | msgid "Authors" 16 | msgstr "作者" 17 | 18 | #: ../../AUTHORS:1 19 | msgid "Plim was created by `Maxim Avanov `_." 20 | msgstr "Plim 最初由 `Maxim Avanov `_ 开发。" 21 | 22 | #: ../../AUTHORS:5 23 | msgid "Contributors (in chronological order of the first contribution)" 24 | msgstr "贡献者(按时间顺序排列)" 25 | 26 | #: ../../AUTHORS:7 27 | msgid "Keith Yang - https://github.com/keitheis" 28 | msgstr "" 29 | 30 | #: ../../AUTHORS:8 31 | msgid "iMom0 - https://github.com/imom0" 32 | msgstr "" 33 | 34 | #: ../../AUTHORS:9 35 | msgid "dongweiming - https://github.com/dongweiming" 36 | msgstr "" 37 | 38 | #: ../authors.rst:6 39 | msgid "" 40 | "See also `a list of Slim authors `_." 42 | msgstr "" 43 | "参见 `Slim 作者列表 `_ 。" 45 | -------------------------------------------------------------------------------- /plim/adapters/babelplugin.py: -------------------------------------------------------------------------------- 1 | """gettext message extraction via Babel: http://babel.edgewall.org/""" 2 | from mako.ext.babelplugin import extract as _extract_mako 3 | 4 | from .. import preprocessor_factory 5 | from ..util import StringIO 6 | 7 | 8 | def extractor_factory(preprocessor=None): 9 | if preprocessor is None: 10 | preprocessor = preprocessor_factory() 11 | 12 | def babel_extractor(fileobj, keywords, comment_tags, options): 13 | """ Extract messages from Plim templates. 14 | 15 | :param fileobj: the file-like object the messages should be extracted from 16 | :param keywords: a list of keywords (i.e. function names) that should be 17 | recognized as translation functions 18 | :param comment_tags: a list of translator tags to search for and include 19 | in the results 20 | :param options: a dictionary of additional options (optional) 21 | :return: an iterator over ``(lineno, funcname, message, comments)`` tuples 22 | :rtype: ``iterator`` 23 | """ 24 | raw_data = fileobj.read() 25 | data = preprocessor(raw_data) 26 | for extracted in _extract_mako(StringIO(data), keywords, comment_tags, options): 27 | yield extracted 28 | 29 | return babel_extractor 30 | 31 | # Default Plim extractor 32 | extract = extractor_factory() 33 | -------------------------------------------------------------------------------- /tests/fixtures/literal_one_liners_result.mako: -------------------------------------------------------------------------------- 1 | %if not new_title: 2 |
    3 | %endif 4 | <%include file="content.html"/> 5 | %if not new_title: 6 |
    7 | %endif 8 | <%inherit file="../../base.html"/> 9 | %if c.id: 10 |
    11 | %else: 12 |
    13 | %endif 14 | <%include file="profile.html"/>
    15 | 16 | ${test.variable}(${test.variable}){${test.variable}}[${test.variable}]  ——01.2.2.13 -4)AbcdeабвгдÖ汉语/漢語This is a test 17 | of implicit literal.You must capitalize the first letter 18 | and then indent each following line to make it working.если строки вашего текста начинается с символа, не входящегов состав ASCII-символов в диапазоне от 33 до 126,то вы можете смело оставлять их "как есть". 19 | ${link['text']} 20 | 21 | ${link['text']} 22 | 23 | ${link['text']} 24 | 25 | ${link['text']} -------------------------------------------------------------------------------- /tests/fixtures/python_test.plim: -------------------------------------------------------------------------------- 1 | - python x = 1 2 | y = x + 1 3 | if True: 4 | y += 1 5 | else: 6 | y -= 1 7 | - py 8 | z = y + 1 9 | 10 | 11 | -py 12 | a = z + y + x 13 | -py! from abcde import fghi 14 | from module import func 15 | 16 | -py 17 | a = u'Привет Мир!' 18 | 19 | -py 20 | for i in i_list: 21 | for j in j_list: 22 | print i, j 23 | if i == j: 24 | print "Equal" 25 | if True: 26 | print "True" 27 | 28 | -py 29 | # Test that `embedded markup` is not parsed 30 | a = "`test test`" 31 | 32 | ----------------------------------------------- 33 | text = 'new-style python blocks' 34 | ----------------------------------------------- 35 | div 36 | --- count = 10 37 | for i in range(count): 38 | print i 39 | 40 | div: --- count = 0 41 | count += 1 42 | 43 | div: --- 44 | under_the_line = True 45 | 46 | --------count = 1-------- 47 | for i in range(count): 48 | print i 49 | 50 | -------- # Inline feature is primarily for placing comments as here ------------------ 51 | var = 1 52 | 53 | ---! from datetime import datetime 54 | -------! from json import dumps 55 | 56 | / Emtpy python blocks are not rendered 57 | -------------------------------------------------------------------------------------- 58 | -------------------------- --------------------------- 59 | --- 60 | -------------------------------------------------------------------------------- /docs/locale/authors.pot: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) 2014, Maxim Avanov 3 | # This file is distributed under the same license as the Plim package. 4 | # FIRST AUTHOR , YEAR. 5 | # 6 | #, fuzzy 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: Plim 0.9\n" 10 | "Report-Msgid-Bugs-To: \n" 11 | "POT-Creation-Date: 2015-06-22 20:43+0800\n" 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 13 | "Last-Translator: FULL NAME \n" 14 | "Language-Team: LANGUAGE \n" 15 | "MIME-Version: 1.0\n" 16 | "Content-Type: text/plain; charset=UTF-8\n" 17 | "Content-Transfer-Encoding: 8bit\n" 18 | 19 | #: ../authors.rst:2 20 | # 52c1f7c01fa742ab9fa4a5e1daf1c8ec 21 | msgid "Authors" 22 | msgstr "" 23 | 24 | #: ../../AUTHORS:1 25 | # 9982f035b7ae4f3e87975ca0b835230e 26 | msgid "Plim was created by `Maxim Avanov `_." 27 | msgstr "" 28 | 29 | #: ../../AUTHORS:5 30 | # 5d2cccd2e02e47b594e8b38732ab5927 31 | msgid "Contributors (in chronological order of the first contribution)" 32 | msgstr "" 33 | 34 | #: ../../AUTHORS:7 35 | # f77c06131c1445d1917ca52581d8ffc9 36 | msgid "Keith Yang - https://github.com/keitheis" 37 | msgstr "" 38 | 39 | #: ../../AUTHORS:8 40 | # e842dda9d49f404ea92f4039d10ae3f3 41 | msgid "iMom0 - https://github.com/imom0" 42 | msgstr "" 43 | 44 | #: ../../AUTHORS:9 45 | # 893fb76fafdb44ef863bef98d1e455b0 46 | msgid "dongweiming - https://github.com/dongweiming" 47 | msgstr "" 48 | 49 | #: ../authors.rst:6 50 | # 0d87284253454eeb9b177dc29a204ebc 51 | msgid "See also `a list of Slim authors `_." 52 | msgstr "" 53 | 54 | -------------------------------------------------------------------------------- /docs/locale/zh_CN/LC_MESSAGES/related.po: -------------------------------------------------------------------------------- 1 | # 2 | msgid "" 3 | msgstr "" 4 | "Project-Id-Version: Plim 0.9\n" 5 | "Report-Msgid-Bugs-To: \n" 6 | "POT-Creation-Date: 2015-06-12 16:42+0800\n" 7 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 8 | "Last-Translator: FULL NAME \n" 9 | "Language-Team: LANGUAGE \n" 10 | "MIME-Version: 1.0\n" 11 | "Content-Type: text/plain; charset=UTF-8\n" 12 | "Content-Transfer-Encoding: 8bit\n" 13 | 14 | #: ../related.rst:4 15 | msgid "There is a number of similar projects that you might be interested in." 16 | msgstr "这里列举了一系列与 Plim 相似的项目,你可能会感兴趣:" 17 | 18 | #: ../related.rst:6 19 | msgid "`slimish-jinja2 `_" 20 | msgstr "" 21 | 22 | #: ../related.rst:7 23 | msgid "`PyJade `_" 24 | msgstr "" 25 | 26 | #: ../related.rst:8 27 | msgid "`mint `_" 28 | msgstr "" 29 | 30 | #: ../related.rst:9 31 | msgid "`SHPAML `_" 32 | msgstr "" 33 | 34 | #: ../related.rst:10 35 | msgid "`Yammy `_" 36 | msgstr "" 37 | 38 | #: ../related.rst:11 39 | msgid "`PyHAML `_" 40 | msgstr "" 41 | 42 | #: ../related.rst:12 43 | msgid "`HamlPy `_" 44 | msgstr "" 45 | 46 | #: ../related.rst:14 47 | msgid "" 48 | "See also `a list of Slim related projects `_." 50 | msgstr "" 51 | "这里还有 `一系列与 Slim 相似的项目 `_ 。" 53 | 54 | #: ../related.rst:2 55 | msgid "Related projects" 56 | msgstr "相关项目" 57 | 58 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: "CI" 2 | on: 3 | push: 4 | branches: [ master, develop ] 5 | pull_request: 6 | branches: [ master, develop ] 7 | 8 | jobs: 9 | tests: 10 | strategy: 11 | matrix: 12 | python-version: [ 39, 310 ] 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v2.3.4 16 | with: 17 | submodules: recursive 18 | - uses: cachix/install-nix-action@v12 19 | with: 20 | install_url: https://releases.nixos.org/nix/nix-2.11.1/install 21 | extra_nix_config: "system-features = benchmark kvm" 22 | - name: Run tests on Python${{ matrix.python-version }} 23 | run: | 24 | nix-shell --argstr pyVersion ${{ matrix.python-version }} --run \ 25 | "pip install -e . && pip install -r requirements.txt && pip install -r requirements-test.txt && make test" 26 | 27 | - name: Coveralls 28 | env: 29 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 30 | run: | 31 | nix-shell --argstr pyVersion ${{ matrix.python-version }} --run "coveralls --service=github" 32 | 33 | coveralls: 34 | name: Coveralls [finalize] 35 | needs: tests 36 | runs-on: ubuntu-latest 37 | steps: 38 | - uses: actions/checkout@v2.3.4 39 | with: 40 | submodules: recursive 41 | - uses: cachix/install-nix-action@v12 42 | with: 43 | install_url: https://releases.nixos.org/nix/nix-2.11.1/install 44 | extra_nix_config: "system-features = benchmark kvm" 45 | - name: Coveralls [finalize] 46 | env: 47 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 48 | run: | 49 | nix-shell --run "coveralls --service=github --finish" 50 | -------------------------------------------------------------------------------- /tests/test_cli.py: -------------------------------------------------------------------------------- 1 | import os 2 | import subprocess 3 | import sys 4 | import codecs 5 | import tempfile 6 | import shutil 7 | 8 | from plim import syntax 9 | from plim.console import plimc 10 | from plim.util import PY3K 11 | from . import TestCaseBase 12 | 13 | 14 | class TestCLI(TestCaseBase): 15 | 16 | def setUp(self): 17 | super(TestCLI, self).setUp() 18 | self.mako_syntax = syntax.Mako() 19 | from io import BytesIO 20 | self.stdout = BytesIO() 21 | 22 | def test_cli_mako_output(self): 23 | plimc(['tests/fixtures/unicode_attributes_test.plim'], stdout=self.stdout) 24 | 25 | def test_cli_html_output(self): 26 | plimc(['--html', 'tests/fixtures/unicode_attributes_test.plim'], stdout=self.stdout) 27 | 28 | def test_custom_preprocessor(self): 29 | initial_cwd = os.getcwd() 30 | tmp_dir = tempfile.mkdtemp() 31 | os.chdir(tmp_dir) 32 | 33 | # copy test module into the temporary dir 34 | test_items = ( 35 | ('custom_parser_module.py', 'a.py'), 36 | ('custom_parser_template.plim', 'a.plim') 37 | ) 38 | for item_src, item_dest in test_items: 39 | item_src = os.path.join(initial_cwd, 'tests', 'cli_fixtures', item_src) 40 | item_dest = os.path.join(tmp_dir, item_dest) 41 | shutil.copy(item_src, item_dest) 42 | 43 | # Make tests 44 | data = subprocess.Popen( 45 | ['plimc', '-p', 'a:custom_preprocessor', 'a.plim'], 46 | stdin=subprocess.PIPE, 47 | stdout=subprocess.PIPE 48 | ).communicate()[0] 49 | data = codecs.decode(data, 'utf-8') 50 | 51 | self.assertNotEqual(initial_cwd, os.getcwd()) 52 | self.assertIn('', sys.path) 53 | self.assertEqual(data, '') 54 | 55 | # Cleanup 56 | os.chdir(initial_cwd) 57 | shutil.rmtree(tmp_dir) 58 | -------------------------------------------------------------------------------- /tests/fixtures/literal_one_liners_test.plim: -------------------------------------------------------------------------------- 1 | -if not new_title 2 |
    3 | 4 | -include content.html 5 | 6 | -if not new_title 7 |
    8 | /------------------------------------ 9 | -inherit ../../base.html 10 | -if c.id 11 |
    12 | -else 13 |
    14 | 15 | -include profile.html 16 |
    17 | /------------------------------------- 18 | ${test.variable} 19 | (${test.variable}) 20 | {${test.variable}} 21 | [${test.variable}] 22 |    23 | —— 24 | 0 25 | 1. 26 | 2. 27 | 2.1 28 | 3 - 29 | 4) 30 | 31 | / ----------------------------------------------- 32 | Test non-ASCII one-liners and capitalized words 33 | ----------------------------------------------- 34 | Abcde 35 | абвгд 36 | Ö 37 | 汉语/漢語 38 | / ----------------------------------------------- 39 | Test implicit literals 40 | ----------------------------------------------- 41 | This is a test 42 | of implicit literal. 43 | You must capitalize the first letter 44 | and then indent each following line to make it working. 45 | 46 | если строки вашего текста начинается с символа, не входящего 47 | в состав ASCII-символов в диапазоне от 33 до 126, 48 | то вы можете смело оставлять их "как есть". 49 | 50 | 51 | a#${link.get('id', 'sidenav-{}'.format(i))} href=link['url'] = link['text'] 52 | 53 | 54 | 55 | a#${link.get('id', 'sidenav-{}'.format(i))} href=link['url'] = link['text'] 56 | 57 | 58 | 59 | a#${ 60 | link.get('id', 'sidenav-{}'.format(i)) 61 | }.${asl_class} href=link['url'] \ 62 | data-cache=cache \ 63 | data-frame=frame = link['text'] 64 | 65 | 66 | a#${test+ 67 | link.get('id', 'sidenav-{}'.format(i)) 68 | +test}.${test+ 69 | asl_class 70 | } href=link['url'] \ 71 | data-cache=cache \ 72 | data-frame=frame = link['text'] 73 | -------------------------------------------------------------------------------- /default.nix: -------------------------------------------------------------------------------- 1 | # https://nixos.wiki/wiki/Development_environment_with_nix-shell 2 | { pkgs ? (import ./nixpkgs).pkgs 3 | , pyVersion ? "310" 4 | }: 5 | 6 | let 7 | 8 | python = pkgs."python${pyVersion}Full"; 9 | pythonPkgs = pkgs."python${pyVersion}Packages"; 10 | 11 | devEnv = pkgs.mkShellNoCC { 12 | name = "plim-devenv"; 13 | 14 | # The packages in the `buildInputs` list will be added to the PATH in our shell 15 | # Python-specific guide: 16 | # https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/python.section.md 17 | nativeBuildInputs = with pkgs; [ 18 | # see https://nixos.org/nixos/packages.html 19 | # Python distribution 20 | python 21 | pythonPkgs.virtualenv 22 | pythonPkgs.wheel 23 | pythonPkgs.twine 24 | pythonPkgs.coveralls 25 | 26 | gnumake 27 | nodejs 28 | nodePackages.npm 29 | taglib 30 | ncurses 31 | libxml2 32 | libxslt 33 | libzip 34 | zlib 35 | # root CA certificates 36 | cacert 37 | which 38 | ]; 39 | shellHook = '' 40 | # set SOURCE_DATE_EPOCH so that we can use python wheels 41 | export SOURCE_DATE_EPOCH=$(date +%s) 42 | 43 | VENV_DIR=$PWD/.venv 44 | 45 | export PATH=$VENV_DIR/bin:$PATH 46 | export PYTHONPATH="" 47 | export LANG=en_GB.UTF-8 48 | 49 | # https://python-poetry.org/docs/configuration/ 50 | export PIP_CACHE_DIR="$PWD/.local/pip-cache${pyVersion}" 51 | 52 | # Setup virtualenv 53 | if [ ! -d $VENV_DIR ]; then 54 | virtualenv $PWD/.venv 55 | $VENV_DIR/bin/python -m pip install -e $PWD 56 | $VENV_DIR/bin/python -m pip install -r $PWD/requirements.txt 57 | fi 58 | 59 | if [ ! -d $PWD/node_modules ]; then 60 | npm install stylus 61 | fi 62 | ''; 63 | }; 64 | 65 | in 66 | { 67 | inherit devEnv; 68 | } 69 | -------------------------------------------------------------------------------- /docs/locale/related.pot: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) 2014, Maxim Avanov 3 | # This file is distributed under the same license as the Plim package. 4 | # FIRST AUTHOR , YEAR. 5 | # 6 | #, fuzzy 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: Plim 0.9\n" 10 | "Report-Msgid-Bugs-To: \n" 11 | "POT-Creation-Date: 2015-06-22 20:43+0800\n" 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 13 | "Last-Translator: FULL NAME \n" 14 | "Language-Team: LANGUAGE \n" 15 | "MIME-Version: 1.0\n" 16 | "Content-Type: text/plain; charset=UTF-8\n" 17 | "Content-Transfer-Encoding: 8bit\n" 18 | 19 | #: ../related.rst:2 20 | # 7a14d207d98846a19842d032f2c9b0d8 21 | msgid "Related projects" 22 | msgstr "" 23 | 24 | #: ../related.rst:4 25 | # 60149bc6ea094872829fc6a6961e9917 26 | msgid "There is a number of similar projects that you might be interested in." 27 | msgstr "" 28 | 29 | #: ../related.rst:6 30 | # 4093e94ac0c74e7e8d3cb0c5bec43fa9 31 | msgid "`slimish-jinja2 `_" 32 | msgstr "" 33 | 34 | #: ../related.rst:7 35 | # 30bc1c4f11df4afaad7ca82be09a5750 36 | msgid "`PyJade `_" 37 | msgstr "" 38 | 39 | #: ../related.rst:8 40 | # ef35f525f8dd434a9e60865b34776dea 41 | msgid "`mint `_" 42 | msgstr "" 43 | 44 | #: ../related.rst:9 45 | # 49d1cb3f5d3b432dae4155d46a18207b 46 | msgid "`SHPAML `_" 47 | msgstr "" 48 | 49 | #: ../related.rst:10 50 | # d517eba85f194b308e8660700da31c0e 51 | msgid "`Yammy `_" 52 | msgstr "" 53 | 54 | #: ../related.rst:11 55 | # 35e39aecb1ad47a8878c76840216c0a9 56 | msgid "`PyHAML `_" 57 | msgstr "" 58 | 59 | #: ../related.rst:12 60 | # f85fba0a1d124672a9353ba796d1a5dd 61 | msgid "`HamlPy `_" 62 | msgstr "" 63 | 64 | #: ../related.rst:14 65 | # 9af79d54bd124cf497c33fb1e0a4be74 66 | msgid "See also `a list of Slim related projects `_." 67 | msgstr "" 68 | 69 | -------------------------------------------------------------------------------- /docs/frameworks.rst: -------------------------------------------------------------------------------- 1 | ======================= 2 | Framework Integration 3 | ======================= 4 | 5 | 6 | Pyramid 7 | ========= 8 | 9 | Add ``plim.adapters.pyramid_renderer`` into the ``pyramid.includes`` list of your .ini configuration file 10 | 11 | .. code-block:: ini 12 | 13 | [app:main] 14 | pyramid.includes = 15 | # ... (other packages) 16 | plim.adapters.pyramid_renderer 17 | 18 | The adapter will add the ``.plim`` renderer for use in Pyramid. This can be overridden and more may be 19 | added via the ``config.add_plim_renderer()`` directive: 20 | 21 | .. code-block:: python 22 | 23 | config.add_plim_renderer('.plm', mako_settings_prefix='mako.') 24 | 25 | The renderer will load its configuration from a provided mako prefix in the Pyramid 26 | settings dictionary. The default prefix is 'mako.'. 27 | 28 | Flask 29 | ====== 30 | 31 | First install the flask_mako package. The following code snippet would get Flask working with plim: 32 | 33 | .. code-block:: python 34 | 35 | from flask import Flask 36 | from flask_mako import MakoTemplates, render_template 37 | from plim import preprocessor 38 | 39 | app = Flask(__name__, template_folder='.') 40 | mako = MakoTemplates(app) 41 | app.config['MAKO_PREPROCESSOR'] = preprocessor 42 | 43 | @app.route('/') 44 | def hello(): 45 | return render_template('hello.html', name='mako') 46 | 47 | if __name__ == "__main__": 48 | app.run(debug=True) 49 | 50 | 51 | With hello.html in templates dir: 52 | 53 | .. code-block:: html 54 | 55 | doctype html 56 | html 57 | head 58 | title hello ${name} 59 | body 60 | p hello ${name} 61 | 62 | 63 | 64 | Syntax Highlighters 65 | ====================== 66 | 67 | At this moment, Plim doesn't have syntax highlighters. 68 | 69 | But, at a starting point you can use 70 | `Slim syntax highlighters `_, 71 | since most of Plim syntax is the same as of Slim. 72 | 73 | Editors support 74 | ---------------- 75 | 76 | 77 | * `vim-plim `_ - a Plim port of `vim-slim `_ plugin. 78 | 79 | 80 | -------------------------------------------------------------------------------- /docs/locale/zh_CN/LC_MESSAGES/index.po: -------------------------------------------------------------------------------- 1 | # 2 | msgid "" 3 | msgstr "" 4 | "Project-Id-Version: Plim 0.9\n" 5 | "Report-Msgid-Bugs-To: \n" 6 | "POT-Creation-Date: 2015-06-12 16:42+0800\n" 7 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 8 | "Last-Translator: FULL NAME \n" 9 | "Language-Team: LANGUAGE \n" 10 | "MIME-Version: 1.0\n" 11 | "Content-Type: text/plain; charset=UTF-8\n" 12 | "Content-Transfer-Encoding: 8bit\n" 13 | 14 | #: ../index.rst:8 15 | msgid "Plim Documentation" 16 | msgstr "Plim 中文文档" 17 | 18 | #: ../index.rst:23 19 | msgid "" 20 | "Plim is a Python port of `Ruby's Slim template language `_ built on top of `Mako Templates " 22 | "`_. It uses `Mako's preprocessor feature " 23 | "`_ to translate its syntax into a valid HTML/Mako markup." 25 | msgstr "" 26 | "Plim 是 `Ruby Slim 模版 `_ 的 Python 移植版本, 27 | "基于 `Mako Templates `_ ,并使用 `Mako 预处理特性 " 28 | "`_ 将其语法转换为符合 HTML/Mako 标准的标签。" 30 | 31 | #: ../index.rst:30 32 | msgid "Installation" 33 | msgstr "安装指南" 34 | 35 | #: ../index.rst:38 36 | msgid "Tests" 37 | msgstr "运行测试" 38 | 39 | #: ../index.rst:40 40 | msgid "" 41 | "Plim provides an extensive test suite based on `nosetests " 42 | "`_. You can run the tests with the " 43 | "following command" 44 | msgstr "" 45 | "Plim 的测试依赖于 `nosetests " 46 | "`_ ,你可以输入下面的命令来运行测试" 47 | 48 | #: ../index.rst:48 49 | msgid "" 50 | "Coverage statistics are `available online " 51 | "`_." 52 | msgstr "" 53 | "你可以在 `这里 " 54 | "`_ 看到覆盖率统计。" 55 | 56 | #: ../index.rst:52 57 | msgid "Detailed example" 58 | msgstr "示例" 59 | 60 | #: ../index.rst:166 61 | msgid "Main Documentation" 62 | msgstr "主要文档" 63 | 64 | #: ../index.rst:183 65 | msgid "Indices and tables" 66 | msgstr "" 67 | 68 | #: ../index.rst:185 69 | msgid ":ref:`genindex`" 70 | msgstr "" 71 | 72 | #: ../index.rst:186 73 | msgid ":ref:`modindex`" 74 | msgstr "" 75 | 76 | #: ../index.rst:187 77 | msgid ":ref:`search`" 78 | msgstr "" 79 | -------------------------------------------------------------------------------- /docs/locale/index.pot: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) 2014, Maxim Avanov 3 | # This file is distributed under the same license as the Plim package. 4 | # FIRST AUTHOR , YEAR. 5 | # 6 | #, fuzzy 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: Plim 0.9\n" 10 | "Report-Msgid-Bugs-To: \n" 11 | "POT-Creation-Date: 2015-06-22 20:43+0800\n" 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 13 | "Last-Translator: FULL NAME \n" 14 | "Language-Team: LANGUAGE \n" 15 | "MIME-Version: 1.0\n" 16 | "Content-Type: text/plain; charset=UTF-8\n" 17 | "Content-Transfer-Encoding: 8bit\n" 18 | 19 | #: ../index.rst:8 20 | # f6f4c1e6d7a04a0da2b2f13c1843cd56 21 | msgid "Plim Documentation" 22 | msgstr "" 23 | 24 | #: ../index.rst:23 25 | # 2eaa426688a24a7693aa151b8e525aa8 26 | msgid "Plim is a Python port of `Ruby's Slim template language `_ built on top of `Mako Templates `_. It uses `Mako's preprocessor feature `_ to translate its syntax into a valid HTML/Mako markup." 27 | msgstr "" 28 | 29 | #: ../index.rst:30 30 | # aeef021e407a41c4b53890e7126b63ae 31 | msgid "Installation" 32 | msgstr "" 33 | 34 | #: ../index.rst:38 35 | # ea6938fb83b3498a8d9d8ae3654acd20 36 | msgid "Tests" 37 | msgstr "" 38 | 39 | #: ../index.rst:40 40 | # 2075f9ace53449618d8eb6bf0edbfafa 41 | msgid "Plim provides an extensive test suite based on `nosetests `_. You can run the tests with the following command" 42 | msgstr "" 43 | 44 | #: ../index.rst:48 45 | # b8140d2d86eb4e57b29ed8d629d8848d 46 | msgid "Coverage statistics are `available online `_." 47 | msgstr "" 48 | 49 | #: ../index.rst:52 50 | # 18b7199b5bc946e3a9694716490b086e 51 | msgid "Detailed example" 52 | msgstr "" 53 | 54 | #: ../index.rst:166 55 | # a3ee0818fde642c9b696899899169fe0 56 | msgid "Main Documentation" 57 | msgstr "" 58 | 59 | #: ../index.rst:183 60 | # 632a1c8d3c7349958ec3754e3c6f3423 61 | msgid "Indices and tables" 62 | msgstr "" 63 | 64 | #: ../index.rst:185 65 | # d90dfb1201c6481eb978fdd20044cc37 66 | msgid ":ref:`genindex`" 67 | msgstr "" 68 | 69 | #: ../index.rst:186 70 | # 5a554d3b01854993a51cf28ce31fd34b 71 | msgid ":ref:`modindex`" 72 | msgstr "" 73 | 74 | #: ../index.rst:187 75 | # e8f102f4d12047649caaf614f88e935f 76 | msgid ":ref:`search`" 77 | msgstr "" 78 | 79 | -------------------------------------------------------------------------------- /plim/adapters/pyramid_renderer.py: -------------------------------------------------------------------------------- 1 | import copy 2 | try: 3 | from pyramid_mako import MakoRendererFactory 4 | from pyramid_mako import parse_options_from_settings 5 | from pyramid_mako import PkgResourceTemplateLookup 6 | except ImportError: 7 | raise NotImplementedError( 8 | "It seems that you are trying to integrate Plim with Pyramid. " 9 | "To do so, please install Pyramid>=1.5 and pyramid_mako>=0.3.1 template bindings." 10 | ) 11 | 12 | 13 | def add_plim_renderer(config, extension, mako_settings_prefix='mako.', preprocessor='plim.preprocessor'): 14 | """ 15 | Register a Plim renderer for a template extension. 16 | 17 | This function is available on the Pyramid configurator after 18 | including the package: 19 | 20 | .. code-block:: python 21 | 22 | config.add_plim_renderer('.plim', mako_settings_prefix='mako.') 23 | 24 | The renderer will load its configuration from a provided mako prefix in the Pyramid 25 | settings dictionary. The default prefix is 'mako.'. 26 | 27 | :param config: Pyramid Config instance 28 | :param extension: renderer file extension 29 | :type extension: str 30 | :param mako_settings_prefix: prefix of mako configuration options. 31 | :type mako_settings_prefix: str 32 | """ 33 | renderer_factory = MakoRendererFactory() 34 | config.add_renderer(extension, renderer_factory) 35 | 36 | def register() -> None: 37 | settings = copy.copy(config.registry.settings) 38 | settings['{prefix}preprocessor'.format(prefix=mako_settings_prefix)] = preprocessor 39 | 40 | opts = parse_options_from_settings(settings, mako_settings_prefix, config.maybe_dotted) 41 | lookup = PkgResourceTemplateLookup(**opts) 42 | 43 | renderer_factory.lookup = lookup 44 | 45 | # read about config.action() at 46 | # http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/extconfig.html#using-config-action-in-a-directive 47 | config.action(('plim-renderer', extension), register) 48 | 49 | 50 | def includeme(config): 51 | """ 52 | Set up standard configurator registrations. Use via: 53 | 54 | .. code-block:: python 55 | 56 | config = Configurator() 57 | config.include('pyramid_mako') 58 | 59 | Once this function has been invoked, the ``.plim`` renderer 60 | is available for use in Pyramid. This can be overridden and more may be 61 | added via the ``config.add_plim_renderer`` directive. 62 | """ 63 | config.add_directive('add_plim_renderer', add_plim_renderer) 64 | config.add_plim_renderer('.plim') 65 | -------------------------------------------------------------------------------- /docs/locale/zh_CN/LC_MESSAGES/frameworks.po: -------------------------------------------------------------------------------- 1 | # 2 | msgid "" 3 | msgstr "" 4 | "Project-Id-Version: Plim 0.9\n" 5 | "Report-Msgid-Bugs-To: \n" 6 | "POT-Creation-Date: 2015-06-12 16:42+0800\n" 7 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 8 | "Last-Translator: FULL NAME \n" 9 | "Language-Team: LANGUAGE \n" 10 | "MIME-Version: 1.0\n" 11 | "Content-Type: text/plain; charset=UTF-8\n" 12 | "Content-Transfer-Encoding: 8bit\n" 13 | 14 | #: ../frameworks.rst:3 15 | msgid "Framework Integration" 16 | msgstr "与 Web 框架集成" 17 | 18 | #: ../frameworks.rst:7 19 | msgid "Pyramid" 20 | msgstr "" 21 | 22 | #: ../frameworks.rst:9 23 | msgid "" 24 | "Add ``plim.adapters.pyramid_renderer`` into the ``pyramid.includes`` list of" 25 | " your .ini configuration file" 26 | msgstr "" 27 | "将 ``plim.adapters.pyramid_renderer`` 添加至项目 .ini 配置文件的 " 28 | "``pyram`id.includes`` 列表中:" 29 | 30 | #: ../frameworks.rst:18 31 | msgid "" 32 | "The adapter will add the ``.plim`` renderer for use in Pyramid. This can be " 33 | "overridden and more may be added via the ``config.add_plim_renderer()`` " 34 | "directive:" 35 | msgstr "" 36 | 37 | #: ../frameworks.rst:25 38 | msgid "" 39 | "The renderer will load its configuration from a provided mako prefix in the " 40 | "Pyramid settings dictionary. The default prefix is 'mako.'." 41 | msgstr "" 42 | 43 | #: ../frameworks.rst:29 44 | msgid "Flask" 45 | msgstr "" 46 | 47 | #: ../frameworks.rst:31 48 | msgid "The following code snippet would get Flask working with plim:" 49 | msgstr "想要在 Flask 中使用 plim 只需要在项目中添加下面的代码:" 50 | 51 | #: ../frameworks.rst:50 52 | msgid "With hello.html in templates dir:" 53 | msgstr "templates 目录中的 hello.html 需要写成这样:" 54 | 55 | #: ../frameworks.rst:64 56 | msgid "Syntax Highlighters" 57 | msgstr "代码高亮" 58 | 59 | #: ../frameworks.rst:66 60 | msgid "At this moment, Plim doesn't have syntax highlighters." 61 | msgstr "现在还没有专门的 plim 语法高亮工具。" 62 | 63 | #: ../frameworks.rst:68 64 | msgid "" 65 | "But, at a starting point you can use `Slim syntax highlighters " 66 | "`_, since most of" 67 | " Plim syntax is the same as of Slim." 68 | msgstr "" 69 | "不过,由于 Plim 和 Slim 的语法很相似,你可以使用 " 70 | "`Slim 的语法高亮工具 `_ " 71 | "作为替代。" 72 | 73 | #: ../frameworks.rst:73 74 | msgid "Editors support" 75 | msgstr "编辑器支持" 76 | 77 | #: ../frameworks.rst:76 78 | msgid "" 79 | "`vim-plim `_ - a Plim port of `vim-" 80 | "slim `_ plugin." 81 | msgstr "" 82 | "`vim-plim `_ —— 一个 Plim 的 " 83 | "`vim-slim `_ 插件移植版本。" 84 | -------------------------------------------------------------------------------- /docs/locale/frameworks.pot: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) 2014, Maxim Avanov 3 | # This file is distributed under the same license as the Plim package. 4 | # FIRST AUTHOR , YEAR. 5 | # 6 | #, fuzzy 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: Plim 0.9\n" 10 | "Report-Msgid-Bugs-To: \n" 11 | "POT-Creation-Date: 2015-06-22 20:43+0800\n" 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 13 | "Last-Translator: FULL NAME \n" 14 | "Language-Team: LANGUAGE \n" 15 | "MIME-Version: 1.0\n" 16 | "Content-Type: text/plain; charset=UTF-8\n" 17 | "Content-Transfer-Encoding: 8bit\n" 18 | 19 | #: ../frameworks.rst:3 20 | # 00313155ff97436badcd2acbba3a3229 21 | msgid "Framework Integration" 22 | msgstr "" 23 | 24 | #: ../frameworks.rst:7 25 | # e436b01dc25c4d3082e8bd47943fe185 26 | msgid "Pyramid" 27 | msgstr "" 28 | 29 | #: ../frameworks.rst:9 30 | # 9c718edf15a1413bae23f8719ce47ca4 31 | msgid "Add ``plim.adapters.pyramid_renderer`` into the ``pyramid.includes`` list of your .ini configuration file" 32 | msgstr "" 33 | 34 | #: ../frameworks.rst:18 35 | # 9910e3441c8a40dfbaa3934ab80e68e7 36 | msgid "The adapter will add the ``.plim`` renderer for use in Pyramid. This can be overridden and more may be added via the ``config.add_plim_renderer()`` directive:" 37 | msgstr "" 38 | 39 | #: ../frameworks.rst:25 40 | # 9b282d6b9545428eafb1f8e79ddcad0c 41 | msgid "The renderer will load its configuration from a provided mako prefix in the Pyramid settings dictionary. The default prefix is 'mako.'." 42 | msgstr "" 43 | 44 | #: ../frameworks.rst:29 45 | # 87678022521b47ccb3eecfa028d3579c 46 | msgid "Flask" 47 | msgstr "" 48 | 49 | #: ../frameworks.rst:31 50 | # 160957593df242d1ae5c3111ff97899a 51 | msgid "The following code snippet would get Flask working with plim:" 52 | msgstr "" 53 | 54 | #: ../frameworks.rst:50 55 | # 7d39b344fc1c4219b38debbf82035cf7 56 | msgid "With hello.html in templates dir:" 57 | msgstr "" 58 | 59 | #: ../frameworks.rst:64 60 | # ea1efa5e20144350b6e99a984d7c0d85 61 | msgid "Syntax Highlighters" 62 | msgstr "" 63 | 64 | #: ../frameworks.rst:66 65 | # 5387495ebd9146f28e1dd5320860ec25 66 | msgid "At this moment, Plim doesn't have syntax highlighters." 67 | msgstr "" 68 | 69 | #: ../frameworks.rst:68 70 | # 89436053f97943a2a13bf14ce51c5ca9 71 | msgid "But, at a starting point you can use `Slim syntax highlighters `_, since most of Plim syntax is the same as of Slim." 72 | msgstr "" 73 | 74 | #: ../frameworks.rst:73 75 | # 71ff4864470944f8875790447d3e5b07 76 | msgid "Editors support" 77 | msgstr "" 78 | 79 | #: ../frameworks.rst:76 80 | # a8e9f4ff68764694b4fc369c4a4e76bf 81 | msgid "`vim-plim `_ - a Plim port of `vim-slim `_ plugin." 82 | msgstr "" 83 | 84 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import io 2 | import os 3 | import sys 4 | 5 | from setuptools import find_packages 6 | from setuptools import setup 7 | 8 | 9 | PY3K = sys.version_info >= (3, 0) 10 | here = lambda path: os.path.join(os.path.abspath(os.path.dirname(__file__)), path) 11 | 12 | 13 | def read(*filenames, **kwargs): 14 | encoding = kwargs.get('encoding', 'utf-8') 15 | sep = kwargs.get('sep', '\n') 16 | buf = [] 17 | for filename in filenames: 18 | with io.open(filename, encoding=encoding) as f: 19 | buf.append(f.read()) 20 | return sep.join(buf) 21 | 22 | 23 | requires = [] 24 | with open(here('requirements.txt')) as f: 25 | rows = f.read().strip().split('\n') 26 | for row in rows: 27 | row = row.strip() 28 | if row and not (row.startswith('#') or row.startswith('http')): 29 | requires.append(row) 30 | 31 | 32 | long_description = read( 33 | os.path.join(os.path.dirname(__file__), 'README.rst'), 34 | os.path.join(os.path.dirname(__file__), 'CHANGES'), 35 | ) 36 | 37 | 38 | setup( 39 | name='Plim', 40 | version='1.1.0', 41 | packages=find_packages(exclude=['tests', 'nixpkgs', 'node_modules']), 42 | install_requires=requires, 43 | setup_requires=[], 44 | tests_require=['pytest', 'coverage'], 45 | package_data={ 46 | # If any package contains *.txt or *.rst files, include them 47 | '': ['*.txt', '*.rst'] 48 | }, 49 | include_package_data=True, 50 | 51 | entry_points={ 52 | 'console_scripts': [ 53 | 'plimc = plim.console:plimc', 54 | ] 55 | }, 56 | 57 | # PyPI metadata 58 | # Read more at http://docs.python.org/distutils/setupscript.html#meta-data 59 | author="Maxim Avanov", 60 | author_email="maxim.avanov@gmail.com", 61 | maintainer="Maxim Avanov", 62 | maintainer_email="maxim.avanov@gmail.com", 63 | description="Plim is a Python port of Ruby's Slim template language built on top of Mako Templates", 64 | long_description=long_description, 65 | license="MIT", 66 | url="https://github.com/avanov/Plim", 67 | download_url="https://github.com/avanov/Plim", 68 | keywords="mako templates ruby slim jade pyjade pyramid flask haml pyhaml", 69 | classifiers=[ 70 | 'Development Status :: 5 - Production/Stable', 71 | 'Environment :: Web Environment', 72 | 'Framework :: Pylons', 73 | 'Framework :: Pyramid', 74 | 'Framework :: TurboGears', 75 | 'Intended Audience :: Developers', 76 | 'License :: OSI Approved', 77 | 'License :: OSI Approved :: MIT License', 78 | 'Operating System :: MacOS', 79 | 'Operating System :: Microsoft', 80 | 'Operating System :: POSIX', 81 | 'Programming Language :: Python', 82 | 'Programming Language :: Python :: 3', 83 | 'Topic :: Internet :: WWW/HTTP', 84 | 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', 85 | 'Topic :: Software Development :: Libraries :: Python Modules', 86 | 'Topic :: Software Development :: Pre-processors', 87 | 'Topic :: Text Processing :: Markup :: HTML', 88 | ] 89 | ) 90 | -------------------------------------------------------------------------------- /docs/differences.rst: -------------------------------------------------------------------------------- 1 | Syntactic Differences 2 | ===================== 3 | 4 | Plim is *not the exact* port of Slim. Here is the full list of differences. 5 | 6 | 7 | #. Slim has the ( ``'`` ), ( ``='`` ), and ( ``=='`` ) `line indicators `_. 8 | In Plim, single quote has been replaced by the comma char ( ``,`` ): 9 | 10 | .. code-block:: slim 11 | 12 | , value 13 | =, value 14 | ==, value 15 | 16 | 17 | The change was made in order to get rid of the syntactic ambiguities like these: 18 | 19 | .. code-block:: plim 20 | 21 | / Is this an empty python string or a syntax error caused by the unclosed single quote? 22 | ='' 23 | 24 | / Is this a python string 'u' ('u''' is the correct python syntax) or 25 | a syntax error caused by the unclosed unicode docstring? 26 | ='u''' 27 | 28 | Meanwhile, the comma char is not allowed at the beginning of python expression, 29 | therefore the following code samples are consistent: 30 | 31 | .. code-block:: plim 32 | 33 | / Syntax error at mako runtime caused by the unclosed single quote 34 | =,' 35 | 36 | / Correct and consistent. Produces an empty unicode string followed by an 37 | explicit trailing whitespace 38 | =,u'' 39 | 40 | 41 | In addition, the comma syntax seems more natural, since in formal writing we also add a whitespace 42 | between a comma and the following word (in contrast to apostrophes, which may be written 43 | together with some parts of words - "I'm", "it's" etc). 44 | 45 | 46 | 47 | #. Unlike Slim, Plim does not support square or curly braces for wrapping tag attributes. 48 | You can use only parentheses ``()``: 49 | 50 | .. code-block:: slim 51 | 52 | / For attributes wrapping we can use only parentheses 53 | p(title="Link Title") 54 | h1 class=(item.id == 1 and 'one' or 'unknown') Title 55 | 56 | / Square and curly braces are allowed only in Python and Mako expressions 57 | a#idx-${item.id} href=item.get_link( 58 | **{'argument': 'value'}) = item.attrs['title'] 59 | 60 | 61 | #. In Plim, all html tags **MUST** be written in lowercase. 62 | 63 | This restriction was introduced to support 64 | :ref:`Implicit Literal Blocks ` feature. 65 | 66 | .. code-block:: slim 67 | 68 | doctype 5 69 | html 70 | head 71 | title Page Title 72 | body 73 | p 74 | | Hello, Explicit Literal Block! 75 | p 76 | Hello, Implicit Literal Block! 77 | 78 | 79 | #. You do not have to use the ``|`` (pipe) indicator in ``style`` and ``script`` tags. 80 | 81 | #. Plim does not make distinctions between control structures and embedded filters. 82 | 83 | For example, in Slim you would write ``-if``, ``-for``, and ``coffee:`` (without 84 | preceding dash, but with the colon sign at the tail). 85 | But in Plim, you must write ``-if``, ``-for``, and ``-coffee``. 86 | 87 | #. In contrast to Slim, Plim does not support the ``/!`` line indicator 88 | `which is used as an HTML-comment `_. You can use 89 | raw HTML-comments instead. 90 | -------------------------------------------------------------------------------- /plim/console.py: -------------------------------------------------------------------------------- 1 | """ 2 | This module contains entry points for command-line utilities provided by Plim package. 3 | """ 4 | import sys 5 | import os 6 | import argparse 7 | import codecs 8 | from pkg_resources import get_distribution 9 | from pkg_resources import EntryPoint 10 | 11 | from mako.template import Template 12 | from mako.lookup import TemplateLookup 13 | 14 | 15 | def plimc(args=None, stdout=None): 16 | """This is the `plimc` command line utility 17 | 18 | :param args: list of command-line arguments. If None, then ``sys.argv[1:]`` will be used. 19 | :type args: list or None 20 | :param stdout: file-like object representing stdout. If None, then ``sys.stdout`` will be used. 21 | Custom stdout is used for testing purposes. 22 | :type stdout: None or a file-like object 23 | """ 24 | # Parse arguments 25 | # ------------------------------------ 26 | cli_parser = argparse.ArgumentParser(description='Compile plim source files into mako files.') 27 | cli_parser.add_argument('source', help="path to source plim template") 28 | cli_parser.add_argument('-o', '--output', help="write result to FILE.") 29 | cli_parser.add_argument('-e', '--encoding', default='utf-8', help="content encoding") 30 | cli_parser.add_argument('-p', '--preprocessor', default='plim:preprocessor', 31 | help="Preprocessor instance that will be used for parsing the template") 32 | cli_parser.add_argument('-H', '--html', action='store_true', help="Render HTML output instead of Mako template") 33 | cli_parser.add_argument('-V', '--version', action='version', 34 | version='Plim {}'.format(get_distribution("Plim").version)) 35 | 36 | if args is None: 37 | args = sys.argv[1:] 38 | args = cli_parser.parse_args(args) 39 | 40 | # Get custom preprocessor, if specified 41 | # ------------------------------------- 42 | preprocessor_path = args.preprocessor 43 | # Add an empty string path, so modules located at the current working dir 44 | # are reachable and considered in the first place (see issue #32). 45 | sys.path.insert(0, '') 46 | preprocessor = EntryPoint.parse('x={}'.format(preprocessor_path)).resolve() 47 | 48 | # Render to html, if requested 49 | # ---------------------------- 50 | if args.html: 51 | root_dir = os.path.dirname(os.path.abspath(args.source)) 52 | template_file = os.path.basename(args.source) 53 | lookup = TemplateLookup(directories=[root_dir], 54 | input_encoding=args.encoding, 55 | output_encoding=args.encoding, 56 | preprocessor=preprocessor) 57 | content = lookup.get_template(template_file).render_unicode() 58 | else: 59 | with codecs.open(args.source, 'rb', args.encoding) as fd: 60 | content = preprocessor(fd.read()) 61 | 62 | # Output 63 | # ------------------------------------ 64 | if args.output is None: 65 | if stdout is None: 66 | stdout = sys.stdout.buffer 67 | fd = stdout 68 | content = codecs.encode(content, 'utf-8') 69 | else: 70 | fd = codecs.open(args.output, 'wb', args.encoding) 71 | try: 72 | fd.write(content) 73 | finally: 74 | fd.close() 75 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import os 3 | import codecs 4 | import unittest 5 | import plim 6 | from plim import syntax 7 | 8 | 9 | 10 | class TestCaseBase(unittest.TestCase): 11 | def setUp(self): 12 | here = os.path.abspath(os.path.dirname(__file__)) 13 | self.templates_dir = os.path.join(here, 'fixtures') 14 | self.maxDiff = None 15 | self.syntax = plim.syntax.Mako() 16 | 17 | def tearDown(self): 18 | pass 19 | 20 | def get_file_contents(self, template_name): 21 | return codecs.open(os.path.join(self.templates_dir, template_name), 'r', 'utf-8').read() 22 | 23 | def check_relevant_chars(self, value1, value2): 24 | value1 = value1.strip().replace('\n\n\n\n', '\n\n').replace('\n\n\n', '\n\n').replace('\n\n', '\n') 25 | value2 = value2.strip().replace('\n\n\n\n', '\n\n').replace('\n\n\n', '\n\n').replace('\n\n', '\n') 26 | self.assertEqual(value1, value2) 27 | 28 | 29 | class TestPreprocessorSyntax(TestCaseBase): 30 | 31 | def test_plim(self): 32 | cases = [ 33 | 'pipe', 34 | 'plim_line', 35 | 'if', 36 | 'unless', 37 | 'python', 38 | 'for', 39 | 'while', 40 | 'until', 41 | 'with', 42 | 'try', 43 | 'def_block', 44 | 'style_script', 45 | 'comment', 46 | 'one_liners', 47 | 'mako_text', 48 | 'early_return', 49 | 'call', 50 | 'multiline_variable', 51 | 'literal_one_liners', 52 | 'no_filtering', 53 | 'linebreak', 54 | 'explicit_space', 55 | 'unicode_attributes', 56 | 'inline_conditions', 57 | 'handlebars', 58 | ] 59 | for test_case in cases: 60 | source = self.get_file_contents(test_case + '_test.plim') 61 | result = self.get_file_contents(test_case + '_result.mako') 62 | data = plim.preprocessor(source) 63 | self.check_relevant_chars(data.strip(), result.strip()) 64 | 65 | 66 | def test_dynamic_attributes(self): 67 | test_case = 'dynamic_attributes' 68 | source = self.get_file_contents(test_case + '_test.plim') 69 | result = self.get_file_contents(test_case + '_result.mako') 70 | data = plim.preprocessor(source) 71 | # normalize data 72 | data = data.replace(", YEAR. 5 | # 6 | #, fuzzy 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: Plim 0.9\n" 10 | "Report-Msgid-Bugs-To: \n" 11 | "POT-Creation-Date: 2015-06-22 20:43+0800\n" 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 13 | "Last-Translator: FULL NAME \n" 14 | "Language-Team: LANGUAGE \n" 15 | "MIME-Version: 1.0\n" 16 | "Content-Type: text/plain; charset=UTF-8\n" 17 | "Content-Transfer-Encoding: 8bit\n" 18 | 19 | #: ../differences.rst:2 20 | # fd63c5dd82d847c6b6217c990db2c401 21 | msgid "Syntactic Differences" 22 | msgstr "" 23 | 24 | #: ../differences.rst:4 25 | # 6543dce23d0a49dd84aa3e8392d3f573 26 | msgid "Plim is *not the exact* port of Slim. Here is the full list of differences." 27 | msgstr "" 28 | 29 | #: ../differences.rst:7 30 | # f3f2929b131f45ba84f8ce2e3cfcee08 31 | msgid "Slim has the ( ``'`` ), ( ``='`` ), and ( ``=='`` ) `line indicators `_. In Plim, single quote has been replaced by the comma char ( ``,`` ):" 32 | msgstr "" 33 | 34 | #: ../differences.rst:17 35 | # 7826b242449f48dca65f39d4ee1970f0 36 | msgid "The change was made in order to get rid of the syntactic ambiguities like these:" 37 | msgstr "" 38 | 39 | #: ../differences.rst:28 40 | # 1b608163774543c78d47de11dde0d784 41 | msgid "Meanwhile, the comma char is not allowed at the beginning of python expression, therefore the following code samples are consistent:" 42 | msgstr "" 43 | 44 | #: ../differences.rst:41 45 | # cdce2fe7525d46cd9f60329336fd2485 46 | msgid "In addition, the comma syntax seems more natural, since in formal writing we also add a whitespace between a comma and the following word (in contrast to apostrophes, which may be written together with some parts of words - \"I'm\", \"it's\" etc)." 47 | msgstr "" 48 | 49 | #: ../differences.rst:47 50 | # 47c4d22c877e40f9ae9cc32446a8d435 51 | msgid "Unlike Slim, Plim does not support square or curly braces for wrapping tag attributes. You can use only parentheses ``()``:" 52 | msgstr "" 53 | 54 | #: ../differences.rst:61 55 | # 29992bcf5c9e4a36a01da0e0225866ac 56 | msgid "In Plim, all html tags **MUST** be written in lowercase." 57 | msgstr "" 58 | 59 | #: ../differences.rst:63 60 | # 2a470b5d41b548dda64bed052f282a56 61 | msgid "This restriction was introduced to support :ref:`Implicit Literal Blocks ` feature." 62 | msgstr "" 63 | 64 | #: ../differences.rst:79 65 | # 8a859a687ea444b89adfacaf4fc8f338 66 | msgid "You do not have to use the ``|`` (pipe) indicator in ``style`` and ``script`` tags." 67 | msgstr "" 68 | 69 | #: ../differences.rst:81 70 | # 1637fde6f5aa4a9db414ba1d51fd88bb 71 | msgid "Plim does not make distinctions between control structures and embedded filters." 72 | msgstr "" 73 | 74 | #: ../differences.rst:83 75 | # a2f0ef6306e04b62aeddb1bcaebab475 76 | msgid "For example, in Slim you would write ``-if``, ``-for``, and ``coffee:`` (without preceding dash, but with the colon sign at the tail). But in Plim, you must write ``-if``, ``-for``, and ``-coffee``." 77 | msgstr "" 78 | 79 | #: ../differences.rst:87 80 | # c57b1618796c49fc88ea5d710a71fa80 81 | msgid "In contrast to Slim, Plim does not support the ``/!`` line indicator `which is used as an HTML-comment `_. You can use raw HTML-comments instead." 82 | msgstr "" 83 | 84 | -------------------------------------------------------------------------------- /docs/locale/zh_CN/LC_MESSAGES/differences.po: -------------------------------------------------------------------------------- 1 | # 2 | msgid "" 3 | msgstr "" 4 | "Project-Id-Version: Plim 0.9\n" 5 | "Report-Msgid-Bugs-To: \n" 6 | "POT-Creation-Date: 2015-06-12 16:42+0800\n" 7 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 8 | "Last-Translator: FULL NAME \n" 9 | "Language-Team: LANGUAGE \n" 10 | "MIME-Version: 1.0\n" 11 | "Content-Type: text/plain; charset=UTF-8\n" 12 | "Content-Transfer-Encoding: 8bit\n" 13 | 14 | #: ../differences.rst:2 15 | msgid "Syntactic Differences" 16 | msgstr "语法区别" 17 | 18 | #: ../differences.rst:4 19 | msgid "" 20 | "Plim is *not the exact* port of Slim. Here is the full list of differences." 21 | msgstr "Plim *不是完整的* Slim 移植,两者区别在于:" 22 | 23 | #: ../differences.rst:7 24 | msgid "" 25 | "Slim has the ( ``'`` ), ( ``='`` ), and ( ``=='`` ) `line indicators " 26 | "`_. In Plim, single " 27 | "quote has been replaced by the comma char ( ``,`` ):" 28 | msgstr "" 29 | "Slim 中有 ( ``'`` )、( ``='`` )、( ``=='`` ) ` 三种行内指示符(line indicators)" 30 | "`_ 。Plim 使用 ``,`` 代替 ``'``。" 31 | 32 | #: ../differences.rst:17 33 | msgid "" 34 | "The change was made in order to get rid of the syntactic ambiguities like " 35 | "these:" 36 | msgstr "" 37 | "之所以这样改动,是为了避免这种情况下的语法歧义:" 38 | 39 | #: ../differences.rst:28 40 | msgid "" 41 | "Meanwhile, the comma char is not allowed at the beginning of python " 42 | "expression, therefore the following code samples are consistent:" 43 | msgstr "" 44 | "然而 Python 表达式不允许以逗号起始,因此下面的例子并不会产生歧义" 45 | 46 | #: ../differences.rst:41 47 | msgid "" 48 | "In addition, the comma syntax seems more natural, since in formal writing we" 49 | " also add a whitespace between a comma and the following word (in contrast " 50 | "to apostrophes, which may be written together with some parts of words - " 51 | "\"I'm\", \"it's\" etc)." 52 | msgstr "" 53 | "另外,使用逗号相比引号也更自然,因为我们在书写普通英文单词,如 “I'm”、“it's” 时也会使用单引号。" 54 | 55 | #: ../differences.rst:47 56 | msgid "" 57 | "Unlike Slim, Plim does not support square or curly braces for wrapping tag " 58 | "attributes. You can use only parentheses ``()``:" 59 | msgstr "" 60 | "和 Slim 不同的是,Plim 并不支持方括号或者花括号作为标签属性标记,只允许小括号 ``()`` :" 61 | 62 | #: ../differences.rst:61 63 | msgid "In Plim, all html tags **MUST** be written in lowercase." 64 | msgstr "Plim 中,所有 HTML 标签 **必须** 完全小写:" 65 | 66 | #: ../differences.rst:63 67 | msgid "" 68 | "This restriction was introduced to support :ref:`Implicit Literal Blocks " 69 | "` feature." 70 | msgstr "" 71 | "该限制是为了提供 :ref:`隐式纯文本块(Implicit Literal Blocks) ` 功能。" 72 | 73 | #: ../differences.rst:79 74 | msgid "" 75 | "You do not have to use the ``|`` (pipe) indicator in ``style`` and " 76 | "``script`` tags." 77 | msgstr "不必在 ``style`` and ``script`` 标签中使用 ``|`` (管道符)。" 78 | 79 | #: ../differences.rst:81 80 | msgid "" 81 | "Plim does not make distinctions between control structures and embedded " 82 | "filters." 83 | msgstr "Plim 并不对结构控制和内嵌的过滤器之间加以区别。" 84 | 85 | #: ../differences.rst:83 86 | msgid "" 87 | "For example, in Slim you would write ``-if``, ``-for``, and ``coffee:`` " 88 | "(without preceding dash, but with the colon sign at the tail). But in Plim, " 89 | "you must write ``-if``, ``-for``, and ``-coffee``." 90 | msgstr "" 91 | "在 Slim 中你需要写 ``-if``、``-for`` 以及 ``coffee:`` ," 92 | "但是在 Plim 中你不可以在结尾添加冒号: ``-if``、``-for``、``-coffee``。" 93 | 94 | #: ../differences.rst:87 95 | msgid "" 96 | "In contrast to Slim, Plim does not support the ``/!`` line indicator `which " 97 | "is used as an HTML-comment `_. You can " 98 | "use raw HTML-comments instead." 99 | msgstr "" 100 | "和 Slim 不同,Plim 并不支持 ``/!`` 这样的 `HTML 批量注释 `_ ," 101 | "在 Plim 中你只能使用原生 HTML 注释符。" 102 | 103 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. Plim documentation master file, created by 2 | sphinx-quickstart on Sun Jun 10 21:08:09 2012. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | ========================= 7 | Plim Documentation 8 | ========================= 9 | 10 | .. image:: https://pypip.in/v/Plim/badge.png 11 | :target: https://crate.io/packages/Plim 12 | 13 | .. image:: https://pypip.in/d/Plim/badge.png 14 | :target: https://crate.io/packages/Plim 15 | 16 | .. image:: https://api.travis-ci.org/avanov/Plim.png 17 | :target: https://travis-ci.org/avanov/Plim 18 | 19 | .. image:: https://coveralls.io/repos/avanov/Plim/badge.png?branch=develop 20 | :target: https://coveralls.io/r/avanov/Plim?branch=develop 21 | 22 | 23 | Plim is a Python port of `Ruby's Slim template language `_ 24 | built on top of `Mako Templates `_. 25 | It uses `Mako's preprocessor feature `_ 26 | to translate its syntax into a valid HTML/Mako markup. 27 | 28 | 29 | Installation 30 | ============= 31 | 32 | .. code-block:: bash 33 | 34 | pip install Plim 35 | 36 | 37 | Tests 38 | ======= 39 | 40 | Plim provides an extensive test suite based on 41 | `pytest `_. 42 | You can run the tests with the following command 43 | 44 | .. code-block:: bash 45 | 46 | python -m pytest 47 | 48 | Coverage statistics are `available online `_. 49 | 50 | 51 | Detailed example 52 | ================= 53 | 54 | .. code-block:: plim 55 | 56 | / base.html 57 | -------------------------- 58 | doctype html 59 | html = next.body() 60 | 61 | 62 | .. code-block:: plim 63 | 64 | / helpers.html 65 | -------------------------- 66 | -def other_headers() 67 | meta charset="utf-8" 68 | link rel="stylesheet" href="/static/css/main.css" 69 | 70 | 71 | .. code-block:: plim 72 | 73 | / layout.html 74 | -------------------------- 75 | -inherit base.html 76 | -namespace name="helper" helpers.html 77 | 78 | head 79 | title Plim Example 80 | meta name="keywords" content="template language" 81 | = helper.other_headers() 82 | 83 | script 84 | /* "script" and "style" blocks do not require explicit literal indicator "|" */ 85 | $(content).do_something(); 86 | 87 | style 88 | body { 89 | background:#FFF; 90 | } 91 | 92 | -scss 93 | /* SCSS/SASS extension */ 94 | @option compress: no; 95 | .selector { 96 | a { 97 | display: block; 98 | } 99 | strong { 100 | color: blue; 101 | } 102 | } 103 | 104 | -coffee 105 | # CoffeeScript extension 106 | square = (x) -> x * x 107 | 108 | body 109 | h1 Markup examples 110 | #content.example1 111 | p Nest by indentation 112 |
    113 | p Mix raw HTML and Plim markup 114 |
    115 | 116 | -md 117 | Use Markdown 118 | ============ 119 | 120 | See the syntax on [this page][1]. 121 | 122 | [1]: http://daringfireball.net/projects/markdown/basics 123 | 124 | -rest 125 | or Use reStructuredText 126 | ======================= 127 | 128 | See the syntax on `this page`_. 129 | 130 | .. _this page: http://docutils.sourceforge.net/docs/user/rst/quickref.html 131 | 132 | 133 | -if items 134 | table: -for item in items: tr 135 | td = item.name 136 | td = item.price 137 | -elif show_empty 138 | p No items found 139 | -else 140 | a href=request.route_url('items.add') =, _('Add items') 141 | 142 | -unless user.authenticated 143 | p Please, sign in. 144 | -else 145 | p Welcome, ${user.name}! 146 | ul 147 | --- i = 0 148 | limit = 5 149 | 150 | -while i < limit 151 | li#idx-${i}.up: a href='#' title="Title" == i 152 | --- i += 1 153 | 154 | -until i < 0 155 | li#idx-${i}.down-${i}: a href='''#''' title="""Title""" ==, i 156 | --- i -= 1 157 | 158 | #footer 159 | Copyright © 2014. 160 | -include footer_links.html 161 | 162 | = render('tracking_code') 163 | 164 | 165 | Main Documentation 166 | =================== 167 | 168 | .. toctree:: 169 | :maxdepth: 3 170 | 171 | syntax 172 | differences 173 | extensions 174 | frameworks 175 | cli 176 | license 177 | authors 178 | related 179 | changes 180 | 181 | 182 | Indices and tables 183 | ================== 184 | 185 | * :ref:`genindex` 186 | * :ref:`modindex` 187 | * :ref:`search` 188 | 189 | -------------------------------------------------------------------------------- /CHANGES: -------------------------------------------------------------------------------- 1 | Changelog 2 | ================ 3 | 4 | 1.0.0 5 | ----- 6 | 7 | - Dropped support for Python 2.x 8 | - Test suite switched from Nose to Pytest 9 | - CI switched from Travis CI to Github Actions 10 | 11 | Version 0.9 12 | ------------- 13 | 14 | - 0.9.12 15 | 16 | - Feature: dashes are now allowed in html tag names. 17 | 18 | - 0.9.11 19 | 20 | - Hotfix: Fix incorrect parsing of templates with windows-style newlines (CR+LF). 21 | 22 | - 0.9.10 23 | 24 | - Hotfix: Fix ``plimc``'s inability to find a custom preprocessors module in the current working dir. 25 | 26 | - 0.9.9 27 | 28 | - Hotfix: Fix UnicodeEncodeError in ``-def`` blocks with unicode strings as default argument values. 29 | 30 | - 0.9.8 31 | 32 | - Change: Stylus extension no longer depends on the ``nib`` package. 33 | 34 | - 0.9.7 35 | 36 | - Hotfix: Include requirements.txt into the distribution. 37 | 38 | - 0.9.6 39 | 40 | - Hotfix: Conditional statements parser now can handle strings containing inline tag separator sequences (#27). 41 | 42 | - 0.9.5 43 | 44 | - Hotfix: Fix ``plimc`` unicode decoding regression introduced by the previous hotfix. 45 | 46 | 47 | - 0.9.4 48 | 49 | - Hotfix: ``plimc`` no longer crashes with TypeError in Python3 environments 50 | when it writes bytes to sys.stdout. 51 | 52 | - 0.9.3 53 | 54 | - Hotfix: Fix UnicodeEncodeError in ``plimc`` when it writes to STDOUT. 55 | 56 | - 0.9.2 57 | 58 | - Feature: added support for `Custom Parsers `_. 59 | 60 | - 0.9.1 61 | 62 | - New Syntax: `New-style Python Blocks `_. 63 | - New Syntax: `New-style Module-level Blocks `_. 64 | 65 | 66 | - 0.9.0 67 | 68 | - Change: Pyramid adapter now relies on Pyramid>=1.5a2 and pyramid_mako>=0.3.1. 69 | - Change: The package now depends on Mako>=0.9.0. 70 | - Change: Sass/Scss extension now requires PyScss>=1.2.0.post3. 71 | - Change: Pyramid adapter's ``plim.file_extension`` configuration option is deprecated. 72 | The ``config.add_plim_renderer()`` `directive is provided instead `_. 73 | 74 | Version 0.8 75 | ------------ 76 | 77 | - 0.8.9 78 | 79 | - Bugfix: Use sys.maxsize instead of unavailable sys.maxint on Python 3. 80 | 81 | - 0.8.8 82 | 83 | - Hotfix: Make Plim working with a development version of pyScss for Python-3.x setups. 84 | 85 | - 0.8.7 86 | 87 | - Bugfix: Pyramid adapter is now compatible with the 1.5a2+ version of the framework. 88 | - Change: `default template file extension `_ 89 | used in pyramid bindings is changed from ".plm" to ".plim". 90 | 91 | - 0.8.6 92 | 93 | - Hotfix: fixed assertion error in handlebars parser. 94 | 95 | - 0.8.5 96 | 97 | - Feature: added support for `Handlebars blocks `_. 98 | 99 | - 0.8.4 100 | 101 | - Hotfix: updated links to github. 102 | 103 | - 0.8.3 104 | 105 | - Hotfix: prevent lexer from parsing embedded markup inside ``style`` and ``script`` blocks. 106 | 107 | - 0.8.2 108 | 109 | - Feature: added support for `Embedded Markup `_. 110 | - Feature: plimc utility is now able to output plain HTML. 111 | 112 | - 0.8.1 113 | 114 | - Feature: added support for `Inline Statements `_. 115 | 116 | - 0.8.0 117 | 118 | - Feature: added support for dynamic attributes unpacker (an equivalent to Slim's splat attributes). 119 | 120 | 121 | Version 0.7 122 | ------------ 123 | 124 | - 0.7.14 125 | 126 | - Hotfix: fixed bug with unicode handling. 127 | 128 | - 0.7.13 129 | 130 | - Hotfix: fixed bug with static unicode attributes. 131 | 132 | - 0.7.12 133 | 134 | - Unnecessary newline characters at the end of literal blocks have been removed. 135 | - Added the command-line tool ``plimc``. 136 | 137 | - 0.7.11 138 | 139 | - Fixed bug that had to do with incorrect parsing of multi-line dynamic class attributes. 140 | - Fixed bug that had to do with passing incorrect data to plim parser in babel adapter. 141 | 142 | - 0.7.10 143 | Fixed bug with unicode error in python block. Thanks to sqrabs@github! 144 | 145 | - 0.7.9 146 | Added babel message extraction plugin. 147 | 148 | - 0.7.8 149 | Expanded range of possible numeric values that don't require double-quoting. 150 | 151 | - 0.7.7 152 | 153 | - Fixed bug with linebreaks without trailing newline character. 154 | - Fixed bug with missing explicit whitespace after ``=,`` and ``==,`` line indicators. 155 | 156 | - 0.7.6 157 | Fixed bug with incorrect parsing of static boolean attributes. 158 | 159 | - 0.7.5 160 | Fixed bug with comment and content blocks separated by empty lines. 161 | 162 | - 0.7.4 163 | Added -stylus extension. 164 | 165 | - 0.7.3 166 | Fix bug with literal one-liners. 167 | 168 | - 0.7.1 169 | Fixed installation error caused by missing README.rst. 170 | 171 | - 0.7.0 172 | Initial public release. -------------------------------------------------------------------------------- /plim/syntax.py: -------------------------------------------------------------------------------- 1 | import re 2 | from typing import Sequence, Any 3 | 4 | from pyrsistent import v, pvector 5 | 6 | from . import lexer as l 7 | 8 | PARSE_IMPLICIT_LITERAL_RE = re.compile( 9 | # Order matters 10 | '(?P(?:' 11 | '\$?\{|\(|\[|&.+;|[0-9]+|' 12 | '(?:' 13 | '[^\u0021-\u007E]' # not ASCII 33 - 126 14 | '|' # or 15 | '[A-Z]' # uppercase latin letters (ASCII 65 - 90) 16 | ')' # It is possible because TAG_RE can match only lowercase tag names 17 | ').*)\s*' 18 | ) 19 | 20 | 21 | class BaseSyntax(object): 22 | VARIABLE_PLACEHOLDER_START_SEQUENCE = '${' 23 | VARIABLE_PLACEHOLDER_END_SEQUENCE = '}' 24 | 25 | STATEMENT_START_START_SEQUENCE = '%' 26 | STATEMENT_START_END_SEQUENCE = ':' 27 | STATEMENT_END_START_SEQUENCE = '%' 28 | STATEMENT_END_END_SEQUENCE = '' 29 | 30 | # Parsers 31 | # ---------------------------------- 32 | PARSE_DOCTYPE_RE = re.compile('doctype\s+(?P[0-9a-z\.]+)', re.IGNORECASE) 33 | PARSE_STYLE_SCRIPT_RE = re.compile('(?:style|script).*', re.IGNORECASE) 34 | PARSE_HANDLEBARS_RE = re.compile('(?:handlebars).*') 35 | PARSE_TAG_TREE_RE = re.compile('(?:#|\.|{tag}).*'.format(tag=l.TAG_RULE)) 36 | # This constant uses l.LITERAL_CONTENT_PREFIX and l.LITERAL_CONTENT_SPACE_PREFIX 37 | PARSE_EXPLICIT_LITERAL_RE = re.compile("(?:\||,).*", re.IGNORECASE) 38 | PARSE_IMPLICIT_LITERAL_RE = PARSE_IMPLICIT_LITERAL_RE 39 | PARSE_RAW_HTML_RE = re.compile('\<.*') 40 | PARSE_VARIABLE_RE = re.compile("=(?P=)?(?P,)?\s*(?P.*)", re.IGNORECASE) 41 | PARSE_COMMENT_RE = re.compile('/.*') 42 | 43 | PARSE_STATEMENTS_RE = re.compile('-\s*(?Pif|for|while|with|try)(?P.*)') 44 | PARSE_FOREIGN_STATEMENTS_RE = re.compile('-\s*(?Punless|until)(?P.*)') 45 | PARSE_PYTHON_NEW_RE = re.compile('---[-]*(?P\!)?\s*(?P[^-].*)?') 46 | PARSE_PYTHON_CLASSIC_RE = re.compile('-\s*(?Ppy(?:thon)?(?P\!?))(?P\s+.*)?') 47 | PARSE_DEF_BLOCK_RE = re.compile('-\s*(?P(?:def|block)(?:\s+.*)?)') 48 | PARSE_MAKO_ONE_LINERS_RE = re.compile('-\s*(?P(?:include|inherit|page|namespace)(?:\s+.*)?)') 49 | PARSE_MAKO_TEXT_RE = re.compile('-\s*(?Ptext(?:\s+.*)?)') 50 | PARSE_CALL_RE = re.compile('-\s*(?Pcall(?:\s+.*)?)') 51 | PARSE_EARLY_RETURN_RE = re.compile('-\s*(?Preturn|continue|break)\s*') 52 | PARSE_EXTENSION_LANGUAGES_RE = re.compile('-\s*(?Pmd|markdown|rst|rest|coffee|scss|sass|stylus)\s*') 53 | 54 | PARSE_ELIF_ELSE_RE = re.compile('-\s*(?Pelif|else)(?P.*)') 55 | PARSE_EXCEPT_ELSE_FINALLY_RE = re.compile('-\s*(?Pexcept|else|finally)(?P.*)') 56 | 57 | def __init__(self, custom_parsers: Sequence[Any] = v()): 58 | """ 59 | :param custom_parsers: a list of 2-tuples of (parser_regex, parser_callable) or None 60 | :type custom_parsers: list or None 61 | """ 62 | if not custom_parsers: 63 | custom_parsers = v() 64 | else: 65 | custom_parsers = pvector(custom_parsers) 66 | 67 | # We initialize standard parsers here rather than in a class' scope, because 68 | # we would like to be able to discard parsers in some syntax implementations by 69 | # replacing them with None (see Django syntax vs. Mako syntax definitions below). 70 | standard_parsers = ( # Order matters 71 | (self.PARSE_STYLE_SCRIPT_RE, l.parse_style_script), 72 | (self.PARSE_DOCTYPE_RE, l.parse_doctype), 73 | (self.PARSE_HANDLEBARS_RE, l.parse_handlebars), 74 | (self.PARSE_TAG_TREE_RE, l.parse_tag_tree), 75 | (self.PARSE_EXPLICIT_LITERAL_RE, l.parse_explicit_literal_with_embedded_markup), 76 | (self.PARSE_IMPLICIT_LITERAL_RE, l.parse_implicit_literal), 77 | (self.PARSE_RAW_HTML_RE, l.parse_raw_html), 78 | (self.PARSE_VARIABLE_RE, l.parse_variable), 79 | (self.PARSE_COMMENT_RE, l.parse_comment), 80 | (self.PARSE_STATEMENTS_RE, l.parse_statements), 81 | (self.PARSE_FOREIGN_STATEMENTS_RE, l.parse_foreign_statements), 82 | (self.PARSE_PYTHON_NEW_RE, l.parse_python_new_style), 83 | (self.PARSE_PYTHON_CLASSIC_RE, l.parse_python), 84 | (self.PARSE_DEF_BLOCK_RE, l.parse_def_block), 85 | (self.PARSE_MAKO_ONE_LINERS_RE, l.parse_mako_one_liners), 86 | (self.PARSE_MAKO_TEXT_RE, l.parse_mako_text), 87 | (self.PARSE_CALL_RE, l.parse_call), 88 | (self.PARSE_EARLY_RETURN_RE, l.parse_early_return), 89 | (self.PARSE_EXTENSION_LANGUAGES_RE, l.parse_markup_languages) 90 | ) 91 | custom_parsers = custom_parsers.extend(standard_parsers) 92 | # discard parsers with None pattern 93 | self.parsers = tuple([p for p in custom_parsers if p[0]]) 94 | 95 | def __str__(self) -> str: 96 | return 'Base Syntax' 97 | 98 | 99 | class Mako(BaseSyntax): 100 | def __str__(self) -> str: 101 | return 'Mako Syntax' 102 | 103 | 104 | class Django(BaseSyntax): 105 | VARIABLE_PLACEHOLDER_START_SEQUENCE = '{{' 106 | VARIABLE_PLACEHOLDER_END_SEQUENCE = '}}' 107 | STATEMENT_START_START_SEQUENCE = '{% ' 108 | STATEMENT_START_END_SEQUENCE = ' %}' 109 | STATEMENT_END_START_SEQUENCE = STATEMENT_START_START_SEQUENCE 110 | STATEMENT_END_END_SEQUENCE = STATEMENT_START_END_SEQUENCE 111 | 112 | PARSE_MAKO_ONE_LINERS_RE = None # type: ignore 113 | PARSE_MAKO_TEXT_RE = None # type: ignore 114 | 115 | def __str__(self): 116 | return 'Django Syntax' 117 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM Command file for Sphinx documentation 4 | 5 | if "%SPHINXBUILD%" == "" ( 6 | set SPHINXBUILD=sphinx-build 7 | ) 8 | set BUILDDIR=_build 9 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . 10 | set I18NSPHINXOPTS=%SPHINXOPTS% . 11 | if NOT "%PAPER%" == "" ( 12 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% 13 | set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% 14 | ) 15 | 16 | if "%1" == "" goto help 17 | 18 | if "%1" == "help" ( 19 | :help 20 | echo.Please use `make ^` where ^ is one of 21 | echo. html to make standalone HTML files 22 | echo. dirhtml to make HTML files named index.html in directories 23 | echo. singlehtml to make a single large HTML file 24 | echo. pickle to make pickle files 25 | echo. json to make JSON files 26 | echo. htmlhelp to make HTML files and a HTML help project 27 | echo. qthelp to make HTML files and a qthelp project 28 | echo. devhelp to make HTML files and a Devhelp project 29 | echo. epub to make an epub 30 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter 31 | echo. text to make text files 32 | echo. man to make manual pages 33 | echo. texinfo to make Texinfo files 34 | echo. gettext to make PO message catalogs 35 | echo. changes to make an overview over all changed/added/deprecated items 36 | echo. linkcheck to check all external links for integrity 37 | echo. doctest to run all doctests embedded in the documentation if enabled 38 | goto end 39 | ) 40 | 41 | if "%1" == "clean" ( 42 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i 43 | del /q /s %BUILDDIR%\* 44 | goto end 45 | ) 46 | 47 | if "%1" == "html" ( 48 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html 49 | if errorlevel 1 exit /b 1 50 | echo. 51 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. 52 | goto end 53 | ) 54 | 55 | if "%1" == "dirhtml" ( 56 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml 57 | if errorlevel 1 exit /b 1 58 | echo. 59 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. 60 | goto end 61 | ) 62 | 63 | if "%1" == "singlehtml" ( 64 | %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml 65 | if errorlevel 1 exit /b 1 66 | echo. 67 | echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. 68 | goto end 69 | ) 70 | 71 | if "%1" == "pickle" ( 72 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle 73 | if errorlevel 1 exit /b 1 74 | echo. 75 | echo.Build finished; now you can process the pickle files. 76 | goto end 77 | ) 78 | 79 | if "%1" == "json" ( 80 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json 81 | if errorlevel 1 exit /b 1 82 | echo. 83 | echo.Build finished; now you can process the JSON files. 84 | goto end 85 | ) 86 | 87 | if "%1" == "htmlhelp" ( 88 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp 89 | if errorlevel 1 exit /b 1 90 | echo. 91 | echo.Build finished; now you can run HTML Help Workshop with the ^ 92 | .hhp project file in %BUILDDIR%/htmlhelp. 93 | goto end 94 | ) 95 | 96 | if "%1" == "qthelp" ( 97 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp 98 | if errorlevel 1 exit /b 1 99 | echo. 100 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ 101 | .qhcp project file in %BUILDDIR%/qthelp, like this: 102 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\Plim.qhcp 103 | echo.To view the help file: 104 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\Plim.ghc 105 | goto end 106 | ) 107 | 108 | if "%1" == "devhelp" ( 109 | %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp 110 | if errorlevel 1 exit /b 1 111 | echo. 112 | echo.Build finished. 113 | goto end 114 | ) 115 | 116 | if "%1" == "epub" ( 117 | %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub 118 | if errorlevel 1 exit /b 1 119 | echo. 120 | echo.Build finished. The epub file is in %BUILDDIR%/epub. 121 | goto end 122 | ) 123 | 124 | if "%1" == "latex" ( 125 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 126 | if errorlevel 1 exit /b 1 127 | echo. 128 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. 129 | goto end 130 | ) 131 | 132 | if "%1" == "text" ( 133 | %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text 134 | if errorlevel 1 exit /b 1 135 | echo. 136 | echo.Build finished. The text files are in %BUILDDIR%/text. 137 | goto end 138 | ) 139 | 140 | if "%1" == "man" ( 141 | %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man 142 | if errorlevel 1 exit /b 1 143 | echo. 144 | echo.Build finished. The manual pages are in %BUILDDIR%/man. 145 | goto end 146 | ) 147 | 148 | if "%1" == "texinfo" ( 149 | %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo 150 | if errorlevel 1 exit /b 1 151 | echo. 152 | echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. 153 | goto end 154 | ) 155 | 156 | if "%1" == "gettext" ( 157 | %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale 158 | if errorlevel 1 exit /b 1 159 | echo. 160 | echo.Build finished. The message catalogs are in %BUILDDIR%/locale. 161 | goto end 162 | ) 163 | 164 | if "%1" == "changes" ( 165 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes 166 | if errorlevel 1 exit /b 1 167 | echo. 168 | echo.The overview file is in %BUILDDIR%/changes. 169 | goto end 170 | ) 171 | 172 | if "%1" == "linkcheck" ( 173 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck 174 | if errorlevel 1 exit /b 1 175 | echo. 176 | echo.Link check complete; look for any errors in the above output ^ 177 | or in %BUILDDIR%/linkcheck/output.txt. 178 | goto end 179 | ) 180 | 181 | if "%1" == "doctest" ( 182 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest 183 | if errorlevel 1 exit /b 1 184 | echo. 185 | echo.Testing of doctests in the sources finished, look at the ^ 186 | results in %BUILDDIR%/doctest/output.txt. 187 | goto end 188 | ) 189 | 190 | :end 191 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = _build 9 | 10 | # Internal variables. 11 | PAPEROPT_a4 = -D latex_paper_size=a4 12 | PAPEROPT_letter = -D latex_paper_size=letter 13 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 14 | # the i18n builder cannot share the environment and doctrees with the others 15 | I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 16 | 17 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext 18 | 19 | help: 20 | @echo "Please use \`make ' where is one of" 21 | @echo " html to make standalone HTML files" 22 | @echo " dirhtml to make HTML files named index.html in directories" 23 | @echo " singlehtml to make a single large HTML file" 24 | @echo " pickle to make pickle files" 25 | @echo " json to make JSON files" 26 | @echo " htmlhelp to make HTML files and a HTML help project" 27 | @echo " qthelp to make HTML files and a qthelp project" 28 | @echo " devhelp to make HTML files and a Devhelp project" 29 | @echo " epub to make an epub" 30 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 31 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 32 | @echo " text to make text files" 33 | @echo " man to make manual pages" 34 | @echo " texinfo to make Texinfo files" 35 | @echo " info to make Texinfo files and run them through makeinfo" 36 | @echo " gettext to make PO message catalogs" 37 | @echo " changes to make an overview of all changed/added/deprecated items" 38 | @echo " linkcheck to check all external links for integrity" 39 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 40 | @echo " chs to make Chinese .mo translation based on the related po files" 41 | 42 | .PHONY: init-chs chs update 43 | 44 | init-chs: gettext update 45 | 46 | update: 47 | sphinx-intl update -p locale -l zh_CN 48 | 49 | chs: 50 | sphinx-intl build 51 | $(SPHINXBUILD) -b html -D language='zh_CN' $(ALLSPHINXOPTS) $(BUILDDIR)/html 52 | @echo "Build finished. The HTML pages are in $(BUILDDIR)." 53 | 54 | clean: 55 | -rm -rf $(BUILDDIR)/* 56 | 57 | html: 58 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 59 | @echo 60 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 61 | 62 | dirhtml: 63 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 64 | @echo 65 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 66 | 67 | singlehtml: 68 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 69 | @echo 70 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 71 | 72 | pickle: 73 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 74 | @echo 75 | @echo "Build finished; now you can process the pickle files." 76 | 77 | json: 78 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 79 | @echo 80 | @echo "Build finished; now you can process the JSON files." 81 | 82 | htmlhelp: 83 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 84 | @echo 85 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 86 | ".hhp project file in $(BUILDDIR)/htmlhelp." 87 | 88 | qthelp: 89 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 90 | @echo 91 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 92 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 93 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Plim.qhcp" 94 | @echo "To view the help file:" 95 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Plim.qhc" 96 | 97 | devhelp: 98 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 99 | @echo 100 | @echo "Build finished." 101 | @echo "To view the help file:" 102 | @echo "# mkdir -p $$HOME/.local/share/devhelp/Plim" 103 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Plim" 104 | @echo "# devhelp" 105 | 106 | epub: 107 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 108 | @echo 109 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 110 | 111 | latex: 112 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 113 | @echo 114 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 115 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 116 | "(use \`make latexpdf' here to do that automatically)." 117 | 118 | latexpdf: 119 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 120 | @echo "Running LaTeX files through pdflatex..." 121 | $(MAKE) -C $(BUILDDIR)/latex all-pdf 122 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 123 | 124 | text: 125 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 126 | @echo 127 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 128 | 129 | man: 130 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 131 | @echo 132 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 133 | 134 | texinfo: 135 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 136 | @echo 137 | @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." 138 | @echo "Run \`make' in that directory to run these through makeinfo" \ 139 | "(use \`make info' here to do that automatically)." 140 | 141 | info: 142 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 143 | @echo "Running Texinfo files through makeinfo..." 144 | make -C $(BUILDDIR)/texinfo info 145 | @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." 146 | 147 | gettext: 148 | $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) locale 149 | @echo 150 | @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." 151 | 152 | changes: 153 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 154 | @echo 155 | @echo "The overview file is in $(BUILDDIR)/changes." 156 | 157 | linkcheck: 158 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 159 | @echo 160 | @echo "Link check complete; look for any errors in the above output " \ 161 | "or in $(BUILDDIR)/linkcheck/output.txt." 162 | 163 | doctest: 164 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 165 | @echo "Testing of doctests in the sources finished, look at the " \ 166 | "results in $(BUILDDIR)/doctest/output.txt." 167 | -------------------------------------------------------------------------------- /docs/locale/extensions.pot: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) 2014, Maxim Avanov 3 | # This file is distributed under the same license as the Plim package. 4 | # FIRST AUTHOR , YEAR. 5 | # 6 | #, fuzzy 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: Plim 0.9\n" 10 | "Report-Msgid-Bugs-To: \n" 11 | "POT-Creation-Date: 2015-06-22 20:43+0800\n" 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 13 | "Last-Translator: FULL NAME \n" 14 | "Language-Team: LANGUAGE \n" 15 | "MIME-Version: 1.0\n" 16 | "Content-Type: text/plain; charset=UTF-8\n" 17 | "Content-Transfer-Encoding: 8bit\n" 18 | 19 | #: ../extensions.rst:2 20 | # 512b2f11fc2c47188aa0cb21a07c1033 21 | msgid "Extensions" 22 | msgstr "" 23 | 24 | #: ../extensions.rst:5 25 | # b4752206bd5548558b18df8bd86b37d5 26 | msgid "Standard extensions" 27 | msgstr "" 28 | 29 | #: ../extensions.rst:8 30 | # 6c674f211c5b49fa979aa8d13fa61571 31 | msgid "CoffeeScript" 32 | msgstr "" 33 | 34 | #: ../extensions.rst:10 35 | # a18c113401fa4867bf17786a267446d7 36 | msgid "Plim uses `Python-CoffeeScript `_ package as a bridge to the JS `CoffeeScript `_ compiler. You can start CoffeeScript block with the ``-coffee`` construct." 37 | msgstr "" 38 | 39 | #: ../extensions.rst:48 40 | # 066f1561a0804f56b23cbe3ef5a827f3 41 | msgid "SCSS/SASS" 42 | msgstr "" 43 | 44 | #: ../extensions.rst:50 45 | # 46902de4e5244aefb0a882bfa29e7bd6 46 | msgid "Plim uses `pyScss `_ package to translate `SCSS/SASS `_ markup to plain CSS. You can start SCSS/SASS block with the ``-scss`` or ``-sass`` construct. The output will be wrapped with ```` tags." 47 | msgstr "" 48 | 49 | #: ../extensions.rst:55 50 | #: ../extensions.rst:90 51 | #: ../extensions.rst:132 52 | #: ../extensions.rst:191 53 | # 45cbbbb44c584a128ce6a94b2a0b9340 54 | # 2f463f2d07844b8a8f8986ee1fe3cae2 55 | # 7c8698d5eac2478b8a51ac98d3df907f 56 | # 5284124e6c28483e99171a11a3e0fa83 57 | msgid "For example," 58 | msgstr "" 59 | 60 | #: ../extensions.rst:70 61 | #: ../extensions.rst:107 62 | #: ../extensions.rst:159 63 | #: ../extensions.rst:211 64 | # 33469c6e60544ee598e13e8606daa34d 65 | # 7f1aea203e4a440290026305c5bf8788 66 | # d35768c9a10e48d7b7971af93be0ea93 67 | # 8295576219b34e468cfd7520cce01556 68 | msgid "produces" 69 | msgstr "" 70 | 71 | #: ../extensions.rst:83 72 | # a5e83e92d2e44299985f09cf04490a7d 73 | msgid "Stylus" 74 | msgstr "" 75 | 76 | #: ../extensions.rst:85 77 | # 21378a06f1974ff8a2cbecc0b3b580ef 78 | msgid "Plim uses `stylus `_ package to translate `stylus `_ markup to plain CSS. You can start Stylus block with the ``-stylus`` construct. The output will be wrapped with ```` tags." 79 | msgstr "" 80 | 81 | #: ../extensions.rst:127 82 | # 4beef184af70461897dab07ea5e52830 83 | msgid "Markdown" 84 | msgstr "" 85 | 86 | #: ../extensions.rst:129 87 | # 1a217118c12248cab92b77ecfe5fa76d 88 | msgid "Plim uses `python-markdown2 `_ package for the ``-markdown`` (or ``-md``) extension." 89 | msgstr "" 90 | 91 | #: ../extensions.rst:186 92 | # 339c154b88054eb9ac81154671c115d7 93 | msgid "reStructuredText" 94 | msgstr "" 95 | 96 | #: ../extensions.rst:188 97 | # 2ea8e053eb63419d84780d54b8c1b498 98 | msgid "Plim uses `Docutils `_ package for both supporting the ``-rest`` (or ``-rst``) extension and project documenting." 99 | msgstr "" 100 | 101 | #: ../extensions.rst:251 102 | # 493f775cbc354bfd91cecb1cbf60d4b7 103 | msgid "Handlebars" 104 | msgstr "" 105 | 106 | #: ../extensions.rst:253 107 | # ae10235e5a7243f2a9ecc7d7ed2348dc 108 | msgid "Plim supports a special tag ``handlebars`` that is translated to a handlebars section declaration:" 109 | msgstr "" 110 | 111 | #: ../extensions.rst:260 112 | # be112f2879e945e3b562b8cbad7cd891 113 | msgid "This is particularly useful to developers using `Ember.js `_." 114 | msgstr "" 115 | 116 | #: ../extensions.rst:262 117 | # 9f419adb749a450ba5b936f3e19fcba1 118 | msgid "Here is an example. The following plim document" 119 | msgstr "" 120 | 121 | #: ../extensions.rst:274 122 | # b841b3deaf7348ebb6a6500256f70f19 123 | msgid "will be rendered as" 124 | msgstr "" 125 | 126 | #: ../extensions.rst:291 127 | # fc7afd4958d84996a1b9bb5c651df203 128 | msgid "Extending Plim with custom parsers" 129 | msgstr "" 130 | 131 | #: ../extensions.rst:295 132 | # 9f205ce9c17e4525b1f0e93e72effbf1 133 | msgid "It is possible to extend standard Plim markup with your own directives. This feature allows you to build your own DSL on top of Plim. For instance, the following example adds a new directive for parsing HTTP links present in a form of ``http_url > title``." 134 | msgstr "" 135 | 136 | #: ../extensions.rst:325 137 | # b3db68e2dcaa45b5935a7fb50e1173e9 138 | msgid "The ``parse_http_link()`` function is defined according to the strict API." 139 | msgstr "" 140 | 141 | #: ../extensions.rst:327 142 | # a1ce9601a9c34970abb0a6d45c5e397d 143 | msgid "Every parser accepts five input arguments:" 144 | msgstr "" 145 | 146 | #: ../extensions.rst:329 147 | # e6d71e8dccd0436aa29f02f69612e6e7 148 | msgid "``indent_level`` - an indentation level of the current line. When the parser reaches a line which indentation is lower or equal to ``indent_level``, it returns control to a top-level function." 149 | msgstr "" 150 | 151 | #: ../extensions.rst:331 152 | # b171860798d8474bb151c42854ca3268 153 | msgid "``current_line`` - a line which is being parsed. This is the line that has been matched by ``matched`` object at the previous parsing step." 154 | msgstr "" 155 | 156 | #: ../extensions.rst:333 157 | # 47f03c5dd1d1440eb8a787c00ea615e1 158 | msgid "``matched`` - an instance of :class:`re.MatchObject` of the regex associated with the current parser." 159 | msgstr "" 160 | 161 | #: ../extensions.rst:334 162 | # 827e2f488f4943aba501efbcbf6b06ae 163 | msgid "``source`` - an instance of an enumerated object returned by :func:`plim.lexer.enumerate_source`." 164 | msgstr "" 165 | 166 | #: ../extensions.rst:335 167 | # 46b230f3f9204113b08cbeb3ed602fff 168 | msgid "``syntax`` - an instance of one of :class:`plim.syntax.BaseSyntax` children." 169 | msgstr "" 170 | 171 | #: ../extensions.rst:337 172 | # 0709e9801ec047e199ae99b9c00885aa 173 | msgid "Every parser returns a 4-tuple of:" 174 | msgstr "" 175 | 176 | #: ../extensions.rst:339 177 | # 3259868813bb4b509864ef0a88506324 178 | msgid "parsed_data - a string of successfully parsed data" 179 | msgstr "" 180 | 181 | #: ../extensions.rst:340 182 | # c71201d92fc74197928da6959af4cf7b 183 | msgid "tail_indent - an indentation level of the ``tail line``" 184 | msgstr "" 185 | 186 | #: ../extensions.rst:341 187 | # 0cf52ab68f474c3abb0c165d2bc51238 188 | msgid "tail_line - a line which indentation level (``tail_indent``) is lower or equal to the input ``indent_level``." 189 | msgstr "" 190 | 191 | #: ../extensions.rst:343 192 | # 8ffbc357e2d148839111540285b5e41f 193 | msgid "``source`` - an instance of enumerated object returned by :func:`plim.lexer.enumerate_source` which represents the remaining (untouched) plim markup." 194 | msgstr "" 195 | 196 | #: ../extensions.rst:347 197 | # 2996315a53594b418a15bf8946c2a024 198 | msgid "From now on, we can use ``custom_preprocessor`` in exactly the same manner as the standard ``plim.preprocessor``." 199 | msgstr "" 200 | 201 | #: ../extensions.rst:350 202 | # 2775aeb34df149ad83a07c74327041d6 203 | msgid "Let's create a plim document with extended syntax:" 204 | msgstr "" 205 | 206 | #: ../extensions.rst:365 207 | # 2ecefd9691e64b199f74e52e282830ee 208 | msgid "Here is how we can compile this document into a valid HTML (note the ``-p`` argument):" 209 | msgstr "" 210 | 211 | #: ../extensions.rst:371 212 | # d464a506dfee44ffb9d246f39c2bbc59 213 | msgid "The result:" 214 | msgstr "" 215 | 216 | -------------------------------------------------------------------------------- /tests/fixtures/reST_test.plim: -------------------------------------------------------------------------------- 1 | -rst 2 | ===================================================== 3 | The reStructuredText_ Cheat Sheet: Syntax Reminders 4 | ===================================================== 5 | :Info: See for introductory docs. 6 | :Author: David Goodger 7 | :Date: $Date: 2011-06-17 10:50:48 +0000 (Fri, 17 Jun 2011) $ 8 | :Revision: $Revision: 7056 $ 9 | :Description: This is a "docinfo block", or bibliographic field list 10 | 11 | Section Structure 12 | ================= 13 | Section titles are underlined or overlined & underlined. 14 | 15 | Body Elements 16 | ============= 17 | Grid table: 18 | 19 | +--------------------------------+-----------------------------------+ 20 | | Paragraphs are flush-left, | Literal block, preceded by "::":: | 21 | | separated by blank lines. | | 22 | | | Indented | 23 | | Block quotes are indented. | | 24 | +--------------------------------+ or:: | 25 | | >>> print 'Doctest block' | | 26 | | Doctest block | > Quoted | 27 | +--------------------------------+-----------------------------------+ 28 | | | Line blocks preserve line breaks & indents. [new in 0.3.6] | 29 | | | Useful for addresses, verse, and adornment-free lists; long | 30 | | lines can be wrapped with continuation lines. | 31 | +--------------------------------------------------------------------+ 32 | 33 | Simple tables: 34 | 35 | ================ ============================================================ 36 | List Type Examples 37 | ================ ============================================================ 38 | Bullet list * items begin with "-", "+", or "*" 39 | Enumerated list 1. items use any variation of "1.", "A)", and "(i)" 40 | #. also auto-enumerated 41 | Definition list Term is flush-left : optional classifier 42 | Definition is indented, no blank line between 43 | Field list :field name: field body 44 | Option list -o at least 2 spaces between option & description 45 | ================ ============================================================ 46 | 47 | ================ ============================================================ 48 | Explicit Markup Examples (visible in the `text source `_) 49 | ================ ============================================================ 50 | Footnote .. [1] Manually numbered or [#] auto-numbered 51 | (even [#labelled]) or [*] auto-symbol 52 | Citation .. [CIT2002] A citation. 53 | Hyperlink Target .. _reStructuredText: http://docutils.sf.net/rst.html 54 | .. _indirect target: reStructuredText_ 55 | .. _internal target: 56 | Anonymous Target __ http://docutils.sf.net/docs/ref/rst/restructuredtext.html 57 | Directive ("::") .. image:: images/biohazard.png 58 | Substitution Def .. |substitution| replace:: like an inline directive 59 | Comment .. is anything else 60 | Empty Comment (".." on a line by itself, with blank lines before & after, 61 | used to separate indentation contexts) 62 | ================ ============================================================ 63 | 64 | Inline Markup 65 | ============= 66 | *emphasis*; **strong emphasis**; `interpreted text`; `interpreted text 67 | with role`:emphasis:; ``inline literal text``; standalone hyperlink, 68 | http://docutils.sourceforge.net; named reference, reStructuredText_; 69 | `anonymous reference`__; footnote reference, [1]_; citation reference, 70 | [CIT2002]_; |substitution|; _`inline internal target`. 71 | 72 | Directive Quick Reference 73 | ========================= 74 | See for full info. 75 | 76 | ================ ============================================================ 77 | Directive Name Description (Docutils version added to, in [brackets]) 78 | ================ ============================================================ 79 | attention Specific admonition; also "caution", "danger", 80 | "error", "hint", "important", "note", "tip", "warning" 81 | admonition Generic titled admonition: ``.. admonition:: By The Way`` 82 | image ``.. image:: picture.png``; many options possible 83 | figure Like "image", but with optional caption and legend 84 | topic ``.. topic:: Title``; like a mini section 85 | sidebar ``.. sidebar:: Title``; like a mini parallel document 86 | parsed-literal A literal block with parsed inline markup 87 | rubric ``.. rubric:: Informal Heading`` 88 | epigraph Block quote with class="epigraph" 89 | highlights Block quote with class="highlights" 90 | pull-quote Block quote with class="pull-quote" 91 | compound Compound paragraphs [0.3.6] 92 | container Generic block-level container element [0.3.10] 93 | table Create a titled table [0.3.1] 94 | list-table Create a table from a uniform two-level bullet list [0.3.8] 95 | csv-table Create a table from CSV data (requires Python 2.3+) [0.3.4] 96 | contents Generate a table of contents 97 | sectnum Automatically number sections, subsections, etc. 98 | header, footer Create document decorations [0.3.8] 99 | target-notes Create an explicit footnote for each external target 100 | math Mathematical notation (input in LaTeX format) 101 | meta HTML-specific metadata 102 | include Read an external reST file as if it were inline 103 | raw Non-reST data passed untouched to the Writer 104 | replace Replacement text for substitution definitions 105 | unicode Unicode character code conversion for substitution defs 106 | date Generates today's date; for substitution defs 107 | class Set a "class" attribute on the next element 108 | role Create a custom interpreted text role [0.3.2] 109 | default-role Set the default interpreted text role [0.3.10] 110 | title Set the metadata document title [0.3.10] 111 | ================ ============================================================ 112 | 113 | Interpreted Text Role Quick Reference 114 | ===================================== 115 | See for full info. 116 | 117 | ================ ============================================================ 118 | Role Name Description 119 | ================ ============================================================ 120 | emphasis Equivalent to *emphasis* 121 | literal Equivalent to ``literal`` but processes backslash escapes 122 | math Mathematical notation (input in LaTeX format) 123 | PEP Reference to a numbered Python Enhancement Proposal 124 | RFC Reference to a numbered Internet Request For Comments 125 | raw For non-reST data; cannot be used directly (see docs) [0.3.6] 126 | strong Equivalent to **strong** 127 | sub Subscript 128 | sup Superscript 129 | title Title reference (book, etc.); standard default role 130 | ================ ============================================================ 131 | -------------------------------------------------------------------------------- /docs/locale/zh_CN/LC_MESSAGES/extensions.po: -------------------------------------------------------------------------------- 1 | # 2 | msgid "" 3 | msgstr "" 4 | "Project-Id-Version: Plim 0.9\n" 5 | "Report-Msgid-Bugs-To: \n" 6 | "POT-Creation-Date: 2015-06-12 16:42+0800\n" 7 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 8 | "Last-Translator: FULL NAME \n" 9 | "Language-Team: LANGUAGE \n" 10 | "MIME-Version: 1.0\n" 11 | "Content-Type: text/plain; charset=UTF-8\n" 12 | "Content-Transfer-Encoding: 8bit\n" 13 | 14 | #: ../extensions.rst:2 15 | msgid "Extensions" 16 | msgstr "扩展" 17 | 18 | #: ../extensions.rst:5 19 | msgid "Standard extensions" 20 | msgstr "标准扩展" 21 | 22 | #: ../extensions.rst:8 23 | msgid "CoffeeScript" 24 | msgstr "" 25 | 26 | #: ../extensions.rst:10 27 | msgid "" 28 | "Plim uses `Python-CoffeeScript `_ package as a bridge to the JS `CoffeeScript " 30 | "`_ compiler. You can start CoffeeScript block with" 31 | " the ``-coffee`` construct." 32 | msgstr "" 33 | "Plim 使用 `Python-CoffeeScript `_ 包" 34 | "作为 JS 与 `CoffeeScript `_ 之间的桥梁。" 35 | "你可以使用 ``-coffee`` 作为 CoffeeScript 代码块标记。" 36 | 37 | #: ../extensions.rst:48 38 | msgid "SCSS/SASS" 39 | msgstr "" 40 | 41 | #: ../extensions.rst:50 42 | msgid "" 43 | "Plim uses `pyScss `_ package to translate " 44 | "`SCSS/SASS `_ markup to plain CSS. You can start " 45 | "SCSS/SASS block with the ``-scss`` or ``-sass`` construct. The output will " 46 | "be wrapped with ```` tags." 47 | msgstr "" 48 | "Plim 使用 `pyScss `_ 包将 " 49 | "`SCSS/SASS `_ 翻译为普通的 CSS。" 50 | "你可以使用 ``-scss`` 或 ``-sass`` 作为 SCSS/SASS 代码块标记。" 51 | "输出结果中将会自动包裹在 ```` 标签中。" 52 | 53 | #: ../extensions.rst:55 ../extensions.rst:90 ../extensions.rst:132 54 | #: ../extensions.rst:191 55 | msgid "For example," 56 | msgstr "例如:" 57 | 58 | #: ../extensions.rst:70 ../extensions.rst:107 ../extensions.rst:159 59 | #: ../extensions.rst:211 60 | msgid "produces" 61 | msgstr "输出:" 62 | 63 | #: ../extensions.rst:83 64 | msgid "Stylus" 65 | msgstr "" 66 | 67 | #: ../extensions.rst:85 68 | msgid "" 69 | "Plim uses `stylus `_ package to " 70 | "translate `stylus `_ markup to plain " 71 | "CSS. You can start Stylus block with the ``-stylus`` construct. The output " 72 | "will be wrapped with ```` tags." 73 | msgstr "" 74 | "Plim 使用 `stylus `_ 包来翻译 " 75 | "`stylus `_ 代码。" 76 | "Stylus 代码使用 ``-stylus`` 标识,输出结果同样会自动添加 ```` 标签。" 77 | 78 | #: ../extensions.rst:127 79 | msgid "Markdown" 80 | msgstr "" 81 | 82 | #: ../extensions.rst:129 83 | msgid "" 84 | "Plim uses `python-markdown2 `_ " 85 | "package for the ``-markdown`` (or ``-md``) extension." 86 | msgstr "" 87 | "Plim 使用 `python-markdown2 `_ " 88 | "包处理 ``-markdown`` (或者 ``-md``)扩展" 89 | 90 | #: ../extensions.rst:186 91 | msgid "reStructuredText" 92 | msgstr "" 93 | 94 | #: ../extensions.rst:188 95 | msgid "" 96 | "Plim uses `Docutils `_ package for both " 97 | "supporting the ``-rest`` (or ``-rst``) extension and project documenting." 98 | msgstr "" 99 | "Plim 使用 `Docutils `_ 包 " 100 | "来处理 ``-rest`` (或者 ``-rst``)扩展以及项目文档。" 101 | 102 | #: ../extensions.rst:251 103 | msgid "Handlebars" 104 | msgstr "Handlebar" 105 | 106 | #: ../extensions.rst:253 107 | msgid "" 108 | "Plim supports a special tag ``handlebars`` that is translated to a " 109 | "handlebars section declaration:" 110 | msgstr "" 111 | "``handlebars`` 是 Plim 支持的一个特殊标签,将会翻译为 ``handlebars`` :" 112 | 113 | #: ../extensions.rst:260 114 | msgid "" 115 | "This is particularly useful to developers using `Ember.js " 116 | "`_." 117 | msgstr "" 118 | "这对 `Ember.js `_ " 119 | "开发者来说非常便利。" 120 | 121 | #: ../extensions.rst:262 122 | msgid "Here is an example. The following plim document" 123 | msgstr "例如,下面的 Plim 文档" 124 | 125 | #: ../extensions.rst:274 126 | msgid "will be rendered as" 127 | msgstr "将会成为" 128 | 129 | #: ../extensions.rst:291 130 | msgid "Extending Plim with custom parsers" 131 | msgstr "使用定制的分析器扩展 Plim" 132 | 133 | #: ../extensions.rst:295 134 | msgid "" 135 | "It is possible to extend standard Plim markup with your own directives. This" 136 | " feature allows you to build your own DSL on top of Plim. For instance, the " 137 | "following example adds a new directive for parsing HTTP links present in a " 138 | "form of ``http_url > title``." 139 | msgstr "" 140 | "你也可以自己扩展 Plim 标签,该功能允许你在 Plim 之上定义自己的 DSL。" 141 | "例如,下面的代码将定义一个新的 HTML 链接解释器," 142 | "将会处理 ``http_url > title`` 形式的链接。" 143 | 144 | #: ../extensions.rst:325 145 | msgid "" 146 | "The ``parse_http_link()`` function is defined according to the strict API." 147 | msgstr "" 148 | "``parse_http_link()`` 函数的定义严格地遵循了 Plim API," 149 | 150 | #: ../extensions.rst:327 151 | msgid "Every parser accepts five input arguments:" 152 | msgstr "所有扩展解释器都应该接受 5 个参数:" 153 | 154 | #: ../extensions.rst:329 155 | msgid "" 156 | "``indent_level`` - an indentation level of the current line. When the parser" 157 | " reaches a line which indentation is lower or equal to ``indent_level``, it " 158 | "returns control to a top-level function." 159 | msgstr "" 160 | "``indent_level`` - 当前行的缩进层次。分析器发现某一行的缩进比上一行多 " 161 | "``indent_level`` 层或更多时,将把它的控制权交给上一层。" 162 | 163 | #: ../extensions.rst:331 164 | msgid "" 165 | "``current_line`` - a line which is being parsed. This is the line that has " 166 | "been matched by ``matched`` object at the previous parsing step." 167 | msgstr "" 168 | "``current_line`` - 已被解析的行列。说明这一行在上一步的解析中已经被 ``matched``" 169 | " 解析器匹配。" 170 | 171 | #: ../extensions.rst:333 172 | msgid "" 173 | "``matched`` - an instance of :class:`re.MatchObject` of the regex associated" 174 | " with the current parser." 175 | msgstr "" 176 | 177 | #: ../extensions.rst:334 178 | msgid "" 179 | "``source`` - an instance of an enumerated object returned by " 180 | ":func:`plim.lexer.enumerate_source`." 181 | msgstr "" 182 | "``source`` - :func:`plim.lexer.enumerate_source` 所返回的枚举对象实例。" 183 | 184 | #: ../extensions.rst:335 185 | msgid "" 186 | "``syntax`` - an instance of one of :class:`plim.syntax.BaseSyntax` children." 187 | msgstr "" 188 | "``syntax`` - :class:`plim.syntax.BaseSyntax` 子类的实例。" 189 | 190 | #: ../extensions.rst:337 191 | msgid "Every parser returns a 4-tuple of:" 192 | msgstr "并返回包含以下元素的元组:" 193 | 194 | #: ../extensions.rst:339 195 | msgid "parsed_data - a string of successfully parsed data" 196 | msgstr "parsed_data - 解释器处理后的字符串。" 197 | 198 | #: ../extensions.rst:340 199 | msgid "tail_indent - an indentation level of the ``tail line``" 200 | msgstr "tail_indent - ``tail line`` 的缩进等级。" 201 | 202 | #: ../extensions.rst:341 203 | msgid "" 204 | "tail_line - a line which indentation level (``tail_indent``) is lower or " 205 | "equal to the input ``indent_level``." 206 | msgstr "" 207 | "tail_line - 缩进等级(``tail_indent``)小于或等于 ``indent_level`` 的行。" 208 | 209 | #: ../extensions.rst:343 210 | msgid "" 211 | "``source`` - an instance of enumerated object returned by " 212 | ":func:`plim.lexer.enumerate_source` which represents the remaining " 213 | "(untouched) plim markup." 214 | msgstr "" 215 | "``source`` - :func:`plim.lexer.enumerate_source` 返回的枚举对象。" 216 | "包含尚未处理的 plim 标记。" 217 | 218 | #: ../extensions.rst:347 219 | msgid "" 220 | "From now on, we can use ``custom_preprocessor`` in exactly the same manner " 221 | "as the standard ``plim.preprocessor``." 222 | msgstr "" 223 | "现在我们已经可以像使用标准 Plim 预处理器 ``plim.preprocessor`` 一样" 224 | "使用 ``custom_preprocessor`` 了。" 225 | 226 | #: ../extensions.rst:350 227 | msgid "Let's create a plim document with extended syntax:" 228 | msgstr "让我们使用新定义的语法来创建一个 plim 文档:" 229 | 230 | #: ../extensions.rst:365 231 | msgid "" 232 | "Here is how we can compile this document into a valid HTML (note the ``-p`` " 233 | "argument):" 234 | msgstr "将会输出这样的有效 HTML (注意 ``-p`` 参数):" 235 | 236 | #: ../extensions.rst:371 237 | msgid "The result:" 238 | msgstr "输出结果:" 239 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Plim documentation build configuration file, created by 4 | # sphinx-quickstart on Tue Jun 12 15:21:53 2012. 5 | # 6 | # This file is execfile()d with the current directory set to its containing dir. 7 | # 8 | # Note that not all possible configuration values are present in this 9 | # autogenerated file. 10 | # 11 | # All configuration values have a default; values that are commented out 12 | # serve to show the default. 13 | 14 | import sys, os 15 | 16 | # If extensions (or modules to document with autodoc) are in another directory, 17 | # add these directories to sys.path here. If the directory is relative to the 18 | # documentation root, use os.path.abspath to make it absolute, like shown here. 19 | #sys.path.insert(0, os.path.abspath('.')) 20 | 21 | # -- General configuration ----------------------------------------------------- 22 | 23 | # If your documentation needs a minimal Sphinx version, state it here. 24 | #needs_sphinx = '1.0' 25 | 26 | # Add any Sphinx extension module names here, as strings. They can be extensions 27 | # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. 28 | extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'sphinx.ext.todo', 'sphinx.ext.coverage', 'sphinx.ext.ifconfig', 'sphinx.ext.viewcode'] 29 | 30 | # Add any paths that contain templates here, relative to this directory. 31 | templates_path = ['_templates'] 32 | 33 | # The suffix of source filenames. 34 | source_suffix = '.rst' 35 | 36 | # The encoding of source files. 37 | #source_encoding = 'utf-8-sig' 38 | 39 | # The master toctree document. 40 | master_doc = 'index' 41 | 42 | # General information about the project. 43 | project = u'Plim' 44 | copyright = u'2014, Maxim Avanov' 45 | 46 | # The version info for the project you're documenting, acts as replacement for 47 | # |version| and |release|, also used in various other places throughout the 48 | # built documents. 49 | # 50 | # The short X.Y version. 51 | version = '1.0' 52 | # The full version, including alpha/beta/rc tags. 53 | release = '1.0.0' 54 | 55 | # The language for content autogenerated by Sphinx. Refer to documentation 56 | # for a list of supported languages. 57 | #language = None 58 | locale_dirs = ['locale/'] 59 | gettext_compact = False 60 | 61 | # There are two options for replacing |today|: either, you set today to some 62 | # non-false value, then it is used: 63 | #today = '' 64 | # Else, today_fmt is used as the format for a strftime call. 65 | #today_fmt = '%B %d, %Y' 66 | 67 | # List of patterns, relative to source directory, that match files and 68 | # directories to ignore when looking for source files. 69 | exclude_patterns = ['_build'] 70 | 71 | # The reST default role (used for this markup: `text`) to use for all documents. 72 | #default_role = None 73 | 74 | # If true, '()' will be appended to :func: etc. cross-reference text. 75 | #add_function_parentheses = True 76 | 77 | # If true, the current module name will be prepended to all description 78 | # unit titles (such as .. function::). 79 | #add_module_names = True 80 | 81 | # If true, sectionauthor and moduleauthor directives will be shown in the 82 | # output. They are ignored by default. 83 | #show_authors = False 84 | 85 | # The name of the Pygments (syntax highlighting) style to use. 86 | pygments_style = 'sphinx' 87 | 88 | # A list of ignored prefixes for module index sorting. 89 | #modindex_common_prefix = [] 90 | 91 | 92 | # -- Options for HTML output --------------------------------------------------- 93 | 94 | # The theme to use for HTML and HTML Help pages. See the documentation for 95 | # a list of builtin themes. 96 | html_theme = 'default' 97 | 98 | # Theme options are theme-specific and customize the look and feel of a theme 99 | # further. For a list of options available for each theme, see the 100 | # documentation. 101 | #html_theme_options = {} 102 | 103 | # Add any paths that contain custom themes here, relative to this directory. 104 | #html_theme_path = [] 105 | 106 | # The name for this set of Sphinx documents. If None, it defaults to 107 | # " v documentation". 108 | #html_title = None 109 | 110 | # A shorter title for the navigation bar. Default is the same as html_title. 111 | #html_short_title = None 112 | 113 | # The name of an image file (relative to this directory) to place at the top 114 | # of the sidebar. 115 | #html_logo = None 116 | 117 | # The name of an image file (within the static path) to use as favicon of the 118 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 119 | # pixels large. 120 | #html_favicon = None 121 | 122 | # Add any paths that contain custom static files (such as style sheets) here, 123 | # relative to this directory. They are copied after the builtin static files, 124 | # so a file named "default.css" will overwrite the builtin "default.css". 125 | html_static_path = ['_static'] 126 | 127 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, 128 | # using the given strftime format. 129 | #html_last_updated_fmt = '%b %d, %Y' 130 | 131 | # If true, SmartyPants will be used to convert quotes and dashes to 132 | # typographically correct entities. 133 | #html_use_smartypants = True 134 | 135 | # Custom sidebar templates, maps document names to template names. 136 | #html_sidebars = {} 137 | 138 | # Additional templates that should be rendered to pages, maps page names to 139 | # template names. 140 | #html_additional_pages = {} 141 | 142 | # If false, no module index is generated. 143 | #html_domain_indices = True 144 | 145 | # If false, no index is generated. 146 | #html_use_index = True 147 | 148 | # If true, the index is split into individual pages for each letter. 149 | #html_split_index = False 150 | 151 | # If true, links to the reST sources are added to the pages. 152 | #html_show_sourcelink = True 153 | 154 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. 155 | #html_show_sphinx = True 156 | 157 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. 158 | #html_show_copyright = True 159 | 160 | # If true, an OpenSearch description file will be output, and all pages will 161 | # contain a tag referring to it. The value of this option must be the 162 | # base URL from which the finished HTML is served. 163 | #html_use_opensearch = '' 164 | 165 | # This is the file name suffix for HTML files (e.g. ".xhtml"). 166 | #html_file_suffix = None 167 | 168 | # Output file base name for HTML help builder. 169 | htmlhelp_basename = 'Plimdoc' 170 | 171 | 172 | # -- Options for LaTeX output -------------------------------------------------- 173 | 174 | latex_elements = { 175 | # The paper size ('letterpaper' or 'a4paper'). 176 | #'papersize': 'letterpaper', 177 | 178 | # The font size ('10pt', '11pt' or '12pt'). 179 | #'pointsize': '10pt', 180 | 181 | # Additional stuff for the LaTeX preamble. 182 | #'preamble': '', 183 | } 184 | 185 | # Grouping the document tree into LaTeX files. List of tuples 186 | # (source start file, target name, title, author, documentclass [howto/manual]). 187 | latex_documents = [ 188 | ('index', 'Plim.tex', u'Plim Documentation', 189 | u'Maxim Avanov', 'manual'), 190 | ] 191 | 192 | # The name of an image file (relative to this directory) to place at the top of 193 | # the title page. 194 | #latex_logo = None 195 | 196 | # For "manual" documents, if this is true, then toplevel headings are parts, 197 | # not chapters. 198 | #latex_use_parts = False 199 | 200 | # If true, show page references after internal links. 201 | #latex_show_pagerefs = False 202 | 203 | # If true, show URL addresses after external links. 204 | #latex_show_urls = False 205 | 206 | # Documents to append as an appendix to all manuals. 207 | #latex_appendices = [] 208 | 209 | # If false, no module index is generated. 210 | #latex_domain_indices = True 211 | 212 | 213 | # -- Options for manual page output -------------------------------------------- 214 | 215 | # One entry per manual page. List of tuples 216 | # (source start file, name, description, authors, manual section). 217 | man_pages = [ 218 | ('index', 'plim', u'Plim Documentation', 219 | [u'Maxim Avanov'], 1) 220 | ] 221 | 222 | # If true, show URL addresses after external links. 223 | #man_show_urls = False 224 | 225 | 226 | # -- Options for Texinfo output ------------------------------------------------ 227 | 228 | # Grouping the document tree into Texinfo files. List of tuples 229 | # (source start file, target name, title, author, 230 | # dir menu entry, description, category) 231 | texinfo_documents = [ 232 | ('index', 'Plim', u'Plim Documentation', 233 | u'Maxim Avanov', 'Plim', 'One line description of project.', 234 | 'Miscellaneous'), 235 | ] 236 | 237 | # Documents to append as an appendix to all manuals. 238 | #texinfo_appendices = [] 239 | 240 | # If false, no module index is generated. 241 | #texinfo_domain_indices = True 242 | 243 | # How to display URL addresses: 'footnote', 'no', or 'inline'. 244 | #texinfo_show_urls = 'footnote' 245 | 246 | 247 | # -- Options for Epub output --------------------------------------------------- 248 | 249 | # Bibliographic Dublin Core info. 250 | epub_title = u'Plim' 251 | epub_author = u'Maxim Avanov' 252 | epub_publisher = u'Maxim Avanov' 253 | epub_copyright = u'2014, Maxim Avanov' 254 | 255 | # The language of the text. It defaults to the language option 256 | # or en if the language is not set. 257 | #epub_language = '' 258 | 259 | # The scheme of the identifier. Typical schemes are ISBN or URL. 260 | #epub_scheme = '' 261 | 262 | # The unique identifier of the text. This can be a ISBN number 263 | # or the project homepage. 264 | #epub_identifier = '' 265 | 266 | # A unique identification for the text. 267 | #epub_uid = '' 268 | 269 | # A tuple containing the cover image and cover page html template filenames. 270 | #epub_cover = () 271 | 272 | # HTML files that should be inserted before the pages created by sphinx. 273 | # The format is a list of tuples containing the path and title. 274 | #epub_pre_files = [] 275 | 276 | # HTML files shat should be inserted after the pages created by sphinx. 277 | # The format is a list of tuples containing the path and title. 278 | #epub_post_files = [] 279 | 280 | # A list of files that should not be packed into the epub file. 281 | #epub_exclude_files = [] 282 | 283 | # The depth of the table of contents in toc.ncx. 284 | #epub_tocdepth = 3 285 | 286 | # Allow duplicate toc entries. 287 | #epub_tocdup = True 288 | 289 | 290 | # Example configuration for intersphinx: refer to the Python standard library. 291 | intersphinx_mapping = {'http://docs.python.org/': None} 292 | -------------------------------------------------------------------------------- /docs/locale/zh_CN/LC_MESSAGES/changes.po: -------------------------------------------------------------------------------- 1 | # 2 | msgid "" 3 | msgstr "" 4 | "Project-Id-Version: Plim 0.9\n" 5 | "Report-Msgid-Bugs-To: \n" 6 | "POT-Creation-Date: 2015-06-12 16:42+0800\n" 7 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 8 | "Last-Translator: FULL NAME \n" 9 | "Language-Team: LANGUAGE \n" 10 | "MIME-Version: 1.0\n" 11 | "Content-Type: text/plain; charset=UTF-8\n" 12 | "Content-Transfer-Encoding: 8bit\n" 13 | 14 | #: ../../CHANGES:2 15 | msgid "Changelog" 16 | msgstr "变更记录" 17 | 18 | #: ../../CHANGES:5 19 | msgid "Version 0.9" 20 | msgstr "" 21 | 22 | #: ../../CHANGES:7 23 | msgid "0.9.11" 24 | msgstr "" 25 | 26 | #: ../../CHANGES:9 27 | msgid "" 28 | "Hotfix: Fix incorrect parsing of templates with windows-style newlines " 29 | "(CR+LF)." 30 | msgstr "Hotfix: Windows-样式换行(CR+LF)的错误解析修复" 31 | 32 | #: ../../CHANGES:11 33 | msgid "0.9.10" 34 | msgstr "" 35 | 36 | #: ../../CHANGES:13 37 | msgid "" 38 | "Hotfix: Fix ``plimc``'s inability to find a custom preprocessors module in " 39 | "the current working dir." 40 | msgstr "Hotfix: 修复 ``plimc`` 无法使用当前目录下的预处理器模块问题。" 41 | 42 | #: ../../CHANGES:15 43 | msgid "0.9.9" 44 | msgstr "" 45 | 46 | #: ../../CHANGES:17 47 | msgid "" 48 | "Hotfix: Fix UnicodeEncodeError in ``-def`` blocks with unicode strings as " 49 | "default argument values." 50 | msgstr "Hotfix: 修复 ``-def`` 代码块中使用 unicode 字符引起的 UnicodeEncodeError 问题。" 51 | 52 | #: ../../CHANGES:19 53 | msgid "0.9.8" 54 | msgstr "" 55 | 56 | #: ../../CHANGES:21 57 | msgid "Change: Stylus extension no longer depends on the ``nib`` package." 58 | msgstr "Change: Stylus 扩展不再依赖于 ``nib`` 包。" 59 | 60 | #: ../../CHANGES:23 61 | msgid "0.9.7" 62 | msgstr "" 63 | 64 | #: ../../CHANGES:25 65 | msgid "Hotfix: Include requirements.txt into the distribution." 66 | msgstr "Hotfix: 将 requirements.txt 包含进发行版中。" 67 | 68 | #: ../../CHANGES:27 69 | msgid "0.9.6" 70 | msgstr "" 71 | 72 | #: ../../CHANGES:29 73 | msgid "" 74 | "Hotfix: Conditional statements parser now can handle strings containing " 75 | "inline tag separator sequences (#27)." 76 | msgstr "" 77 | "Hotfix: Conditional statements parser now can handle strings containing " 78 | "inline tag separator sequences (#27)." 79 | 80 | #: ../../CHANGES:31 81 | msgid "0.9.5" 82 | msgstr "" 83 | 84 | #: ../../CHANGES:33 85 | msgid "" 86 | "Hotfix: Fix ``plimc`` unicode decoding regression introduced by the previous" 87 | " hotfix." 88 | msgstr "Hotfix: 修复在上一个 Hotfix 中引入的 ``plimc`` 解码 Unicode 正则表达式的问题。" 89 | 90 | #: ../../CHANGES:36 91 | msgid "0.9.4" 92 | msgstr "" 93 | 94 | #: ../../CHANGES:39 95 | msgid "" 96 | "Hotfix: ``plimc`` no longer crashes with TypeError in Python3 environments" 97 | msgstr "Hotfix: ``plimc`` 在 Python 3 环境下不会因 TypeError 而崩溃了。" 98 | 99 | #: ../../CHANGES:39 100 | msgid "when it writes bytes to sys.stdout." 101 | msgstr "将输出指向 sys.stdout 。" 102 | 103 | #: ../../CHANGES:41 104 | msgid "0.9.3" 105 | msgstr "" 106 | 107 | #: ../../CHANGES:43 108 | msgid "Hotfix: Fix UnicodeEncodeError in ``plimc`` when it writes to STDOUT." 109 | msgstr "Hotfix: 修复 ``plimc`` 将输出指向 STDOUT 时的 UnicodeEncodeError。" 110 | 111 | #: ../../CHANGES:45 112 | msgid "0.9.2" 113 | msgstr "" 114 | 115 | #: ../../CHANGES:47 116 | msgid "" 117 | "Feature: added support for `Custom Parsers " 118 | "`_." 120 | msgstr "" 121 | "Feature: 添加 `自定义解释器 " 122 | "`_ 特性。" 124 | 125 | #: ../../CHANGES:49 126 | msgid "0.9.1" 127 | msgstr "" 128 | 129 | #: ../../CHANGES:51 130 | msgid "" 131 | "New Syntax: `New-style Python Blocks " 132 | "`_." 133 | msgstr "" 134 | "新语法: `新式 Python 代码块 `_." 136 | 137 | #: ../../CHANGES:55 138 | msgid "0.9.0" 139 | msgstr "" 140 | 141 | #: ../../CHANGES:57 142 | msgid "" 143 | "Change: Pyramid adapter now relies on Pyramid>=1.5a2 and " 144 | "pyramid_mako>=0.3.1." 145 | msgstr "变动:Pyramid 适配器现在依赖于 Pyramid>=1.5a2 以及 pyramid_mako>=0.3.1 。" 146 | 147 | #: ../../CHANGES:58 148 | msgid "Change: The package now depends on Mako>=0.9.0." 149 | msgstr "变动:Plim 现在需要 Mako>=0.9.0 支持。" 150 | 151 | #: ../../CHANGES:59 152 | msgid "Change: Sass/Scss extension now requires PyScss>=1.2.0.post3." 153 | msgstr "变动: Sass/Scss 扩展现在需要 PyScss>=1.2.0.post3 。" 154 | 155 | #: ../../CHANGES:61 156 | msgid "" 157 | "Change: Pyramid adapter's ``plim.file_extension`` configuration option is " 158 | "deprecated." 159 | msgstr "变动:Pyramid 适配器的 ``plim.file_extension`` 设置选项已被标记为不推荐使用。" 160 | 161 | #: ../../CHANGES:61 162 | msgid "" 163 | "The ``config.add_plim_renderer()`` `directive is provided instead " 164 | "`_." 165 | msgstr "" 166 | "``config.add_plim_renderer()`` 已 `被替换 " 167 | "`_ 。" 168 | 169 | #: ../../CHANGES:64 170 | msgid "Version 0.8" 171 | msgstr "" 172 | 173 | #: ../../CHANGES:66 174 | msgid "0.8.9" 175 | msgstr "" 176 | 177 | #: ../../CHANGES:68 178 | msgid "Bugfix: Use sys.maxsize instead of unavailable sys.maxint on Python 3." 179 | msgstr "" 180 | 181 | #: ../../CHANGES:70 182 | msgid "0.8.8" 183 | msgstr "" 184 | 185 | #: ../../CHANGES:72 186 | msgid "" 187 | "Hotfix: Make Plim working with a development version of pyScss for " 188 | "Python-3.x setups." 189 | msgstr "" 190 | 191 | #: ../../CHANGES:74 192 | msgid "0.8.7" 193 | msgstr "" 194 | 195 | #: ../../CHANGES:76 196 | msgid "" 197 | "Bugfix: Pyramid adapter is now compatible with the 1.5a2+ version of the " 198 | "framework." 199 | msgstr "" 200 | 201 | #: ../../CHANGES:78 202 | msgid "" 203 | "Change: `default template file extension " 204 | "`_" 205 | msgstr "" 206 | 207 | #: ../../CHANGES:78 208 | msgid "used in pyramid bindings is changed from \".plm\" to \".plim\"." 209 | msgstr "" 210 | 211 | #: ../../CHANGES:80 212 | msgid "0.8.6" 213 | msgstr "" 214 | 215 | #: ../../CHANGES:82 216 | msgid "Hotfix: fixed assertion error in handlebars parser." 217 | msgstr "" 218 | 219 | #: ../../CHANGES:84 220 | msgid "0.8.5" 221 | msgstr "" 222 | 223 | #: ../../CHANGES:86 224 | msgid "" 225 | "Feature: added support for `Handlebars blocks " 226 | "`_." 227 | msgstr "" 228 | 229 | #: ../../CHANGES:88 230 | msgid "0.8.4" 231 | msgstr "" 232 | 233 | #: ../../CHANGES:90 234 | msgid "Hotfix: updated links to github." 235 | msgstr "" 236 | 237 | #: ../../CHANGES:92 238 | msgid "0.8.3" 239 | msgstr "" 240 | 241 | #: ../../CHANGES:94 242 | msgid "" 243 | "Hotfix: prevent lexer from parsing embedded markup inside ``style`` and " 244 | "``script`` blocks." 245 | msgstr "" 246 | 247 | #: ../../CHANGES:96 248 | msgid "0.8.2" 249 | msgstr "" 250 | 251 | #: ../../CHANGES:98 252 | msgid "" 253 | "Feature: added support for `Embedded Markup " 254 | "`_." 255 | msgstr "" 256 | 257 | #: ../../CHANGES:99 258 | msgid "Feature: plimc utility is now able to output plain HTML." 259 | msgstr "" 260 | 261 | #: ../../CHANGES:101 262 | msgid "0.8.1" 263 | msgstr "" 264 | 265 | #: ../../CHANGES:103 266 | msgid "" 267 | "Feature: added support for `Inline Statements " 268 | "`_." 269 | msgstr "" 270 | 271 | #: ../../CHANGES:105 272 | msgid "0.8.0" 273 | msgstr "" 274 | 275 | #: ../../CHANGES:107 276 | msgid "" 277 | "Feature: added support for dynamic attributes unpacker (an equivalent to " 278 | "Slim's splat attributes)." 279 | msgstr "" 280 | 281 | #: ../../CHANGES:111 282 | msgid "Version 0.7" 283 | msgstr "" 284 | 285 | #: ../../CHANGES:113 286 | msgid "0.7.14" 287 | msgstr "" 288 | 289 | #: ../../CHANGES:115 290 | msgid "Hotfix: fixed bug with unicode handling." 291 | msgstr "" 292 | 293 | #: ../../CHANGES:117 294 | msgid "0.7.13" 295 | msgstr "" 296 | 297 | #: ../../CHANGES:119 298 | msgid "Hotfix: fixed bug with static unicode attributes." 299 | msgstr "" 300 | 301 | #: ../../CHANGES:121 302 | msgid "0.7.12" 303 | msgstr "" 304 | 305 | #: ../../CHANGES:123 306 | msgid "" 307 | "Unnecessary newline characters at the end of literal blocks have been " 308 | "removed." 309 | msgstr "" 310 | 311 | #: ../../CHANGES:124 312 | msgid "Added the command-line tool ``plimc``." 313 | msgstr "" 314 | 315 | #: ../../CHANGES:126 316 | msgid "0.7.11" 317 | msgstr "" 318 | 319 | #: ../../CHANGES:128 320 | msgid "" 321 | "Fixed bug that had to do with incorrect parsing of multi-line dynamic class " 322 | "attributes." 323 | msgstr "" 324 | 325 | #: ../../CHANGES:129 326 | msgid "" 327 | "Fixed bug that had to do with passing incorrect data to plim parser in babel" 328 | " adapter." 329 | msgstr "" 330 | 331 | #: ../../CHANGES:131 332 | msgid "" 333 | "0.7.10 Fixed bug with unicode error in python block. Thanks to " 334 | "sqrabs@github!" 335 | msgstr "" 336 | 337 | #: ../../CHANGES:134 338 | msgid "0.7.9 Added babel message extraction plugin." 339 | msgstr "" 340 | 341 | #: ../../CHANGES:137 342 | msgid "" 343 | "0.7.8 Expanded range of possible numeric values that don't require double-" 344 | "quoting." 345 | msgstr "" 346 | 347 | #: ../../CHANGES:140 348 | msgid "0.7.7" 349 | msgstr "" 350 | 351 | #: ../../CHANGES:142 352 | msgid "Fixed bug with linebreaks without trailing newline character." 353 | msgstr "" 354 | 355 | #: ../../CHANGES:143 356 | msgid "" 357 | "Fixed bug with missing explicit whitespace after ``=,`` and ``==,`` line " 358 | "indicators." 359 | msgstr "" 360 | 361 | #: ../../CHANGES:145 362 | msgid "0.7.6 Fixed bug with incorrect parsing of static boolean attributes." 363 | msgstr "" 364 | 365 | #: ../../CHANGES:148 366 | msgid "" 367 | "0.7.5 Fixed bug with comment and content blocks separated by empty lines." 368 | msgstr "" 369 | 370 | #: ../../CHANGES:151 371 | msgid "0.7.4 Added -stylus extension." 372 | msgstr "" 373 | 374 | #: ../../CHANGES:154 375 | msgid "0.7.3 Fix bug with literal one-liners." 376 | msgstr "" 377 | 378 | #: ../../CHANGES:157 379 | msgid "0.7.1 Fixed installation error caused by missing README.rst." 380 | msgstr "" 381 | 382 | #: ../../CHANGES:160 383 | msgid "0.7.0 Initial public release." 384 | msgstr "" 385 | 386 | #: ../../CHANGES:52 387 | msgid "" 388 | "New Syntax: `New-style Module-level Blocks " 389 | "`_." 391 | msgstr "" 392 | "新语法: `模块级代码块的新式写法 `_ 。" 394 | 395 | -------------------------------------------------------------------------------- /docs/extensions.rst: -------------------------------------------------------------------------------- 1 | Extensions 2 | =========== 3 | 4 | Standard extensions 5 | ------------------- 6 | 7 | CoffeeScript 8 | ~~~~~~~~~~~~ 9 | 10 | Plim uses `Python-CoffeeScript `_ package 11 | as a bridge to the JS `CoffeeScript `_ compiler. 12 | You can start CoffeeScript block with the ``-coffee`` construct. 13 | 14 | .. code-block:: plim 15 | 16 | - coffee 17 | # Assignment: 18 | number = 42 19 | opposite = true 20 | 21 | # Conditions: 22 | number = -42 if opposite 23 | 24 | # Functions: 25 | square = (x) -> x * x 26 | 27 | # Arrays: 28 | list = [1, 2, 3, 4, 5] 29 | 30 | # Objects: 31 | math = 32 | root: Math.sqrt 33 | square: square 34 | cube: (x) -> x * square x 35 | 36 | # Splats: 37 | race = (winner, runners...) -> 38 | print winner, runners 39 | 40 | # Existence: 41 | alert "I knew it!" if elvis? 42 | 43 | # Array comprehensions: 44 | cubes = (math.cube num for num in list) 45 | 46 | 47 | SCSS/SASS 48 | ~~~~~~~~~ 49 | 50 | Plim uses `pyScss `_ package to translate 51 | `SCSS/SASS `_ markup to plain CSS. 52 | You can start SCSS/SASS block with the ``-scss`` or ``-sass`` construct. The output will be 53 | wrapped with ```` tags. 54 | 55 | For example, 56 | 57 | .. code-block:: plim 58 | 59 | - scss 60 | @option compress: no; 61 | .selector { 62 | a { 63 | display: block; 64 | } 65 | strong { 66 | color: blue; 67 | } 68 | } 69 | 70 | produces 71 | 72 | .. code-block:: html 73 | 74 | 80 | 81 | 82 | Stylus 83 | ~~~~~~~~~ 84 | 85 | Plim uses `stylus `_ package to translate 86 | `stylus `_ markup to plain CSS. 87 | You can start Stylus block with the ``-stylus`` construct. The output will be 88 | wrapped with ```` tags. 89 | 90 | For example, 91 | 92 | .. code-block:: plim 93 | 94 | - stylus 95 | @import 'nib' 96 | body 97 | background: linear-gradient(top, white, black) 98 | 99 | border-radius() 100 | -webkit-border-radius arguments 101 | -moz-border-radius arguments 102 | border-radius arguments 103 | 104 | a.button 105 | border-radius 5px 106 | 107 | produces 108 | 109 | .. code-block:: html 110 | 111 | 124 | 125 | 126 | Markdown 127 | ~~~~~~~~ 128 | 129 | Plim uses `python-markdown2 `_ package 130 | for the ``-markdown`` (or ``-md``) extension. 131 | 132 | For example, 133 | 134 | .. code-block:: plim 135 | 136 | - markdown 137 | A First Level Header 138 | ==================== 139 | 140 | A Second Level Header 141 | --------------------- 142 | 143 | Now is the time for all good men to come to 144 | the aid of their country. This is just a 145 | regular paragraph. 146 | 147 | The quick brown fox jumped over the lazy 148 | dog's back. 149 | 150 | ### Header 3 151 | 152 | > This is a blockquote. 153 | > 154 | > This is the second paragraph in the blockquote. 155 | > 156 | > ## This is an H2 in a blockquote 157 | 158 | 159 | produces 160 | 161 | .. code-block:: html 162 | 163 |

    A First Level Header

    164 | 165 |

    A Second Level Header

    166 | 167 |

    Now is the time for all good men to come to 168 | the aid of their country. This is just a 169 | regular paragraph.

    170 | 171 |

    The quick brown fox jumped over the lazy 172 | dog's back.

    173 | 174 |

    Header 3

    175 | 176 |
    177 |

    This is a blockquote.

    178 | 179 |

    This is the second paragraph in the blockquote.

    180 | 181 |

    This is an H2 in a blockquote

    182 |
    183 | 184 | 185 | reStructuredText 186 | ~~~~~~~~~~~~~~~~ 187 | 188 | Plim uses `Docutils `_ package for both supporting 189 | the ``-rest`` (or ``-rst``) extension and project documenting. 190 | 191 | For example, 192 | 193 | .. code-block:: plim 194 | 195 | - rest 196 | Grid table: 197 | 198 | +------------+------------+-----------+ 199 | | Header 1 | Header 2 | Header 3 | 200 | +============+============+===========+ 201 | | body row 1 | column 2 | column 3 | 202 | +------------+------------+-----------+ 203 | | body row 2 | Cells may span columns.| 204 | +------------+------------+-----------+ 205 | | body row 3 | Cells may | - Cells | 206 | +------------+ span rows. | - contain | 207 | | body row 4 | | - blocks. | 208 | +------------+------------+-----------+ 209 | 210 | 211 | produces 212 | 213 | .. code-block:: html 214 | 215 |

    Grid table:

    216 | 217 | 218 | 219 | 223 | 224 | 225 | 226 | 230 | 231 | 234 | 235 | 244 | 245 | 247 |
    Header 1 220 | Header 2 221 | Header 3 222 |
    body row 1 227 | column 2 228 | column 3 229 |
    body row 2 232 | Cells may span columns. 233 |
    body row 3 236 | Cells may
    span rows. 237 |
    238 |
      239 |
    • Cells 240 |
    • contain 241 |
    • blocks. 242 |
    243 |
    body row 4 246 |
    248 | 249 | 250 | Handlebars 251 | ~~~~~~~~~~ 252 | 253 | Plim supports a special tag ``handlebars`` that is translated to a handlebars section declaration: 254 | 255 | .. code-block:: html 256 | 257 | 258 | 259 | 260 | This is particularly useful to developers using `Ember.js `_. 261 | 262 | Here is an example. The following plim document 263 | 264 | .. code-block:: plim 265 | 266 | html 267 | body 268 | handlebars#testapp 269 | .container {{outlet}} 270 | 271 | handlebars#about: .container {{outlet}} 272 | 273 | 274 | will be rendered as 275 | 276 | .. code-block:: html 277 | 278 | 279 | 280 | 283 | 286 | 287 | 288 | 289 | 290 | Extending Plim with custom parsers 291 | ---------------------------------- 292 | 293 | .. versionadded:: 0.9.2 294 | 295 | It is possible to extend standard Plim markup with your own directives. This feature allows you 296 | to build your own DSL on top of Plim. For instance, the following example adds a new directive 297 | for parsing HTTP links present in a form of ``http_url > title``. 298 | 299 | .. code-block:: python 300 | :linenos: 301 | 302 | # my_module.py 303 | import re 304 | from plim import preprocessor_factory 305 | 306 | 307 | PARSE_HTTP_LINKS_RE = re.compile('(?Phttps?://[^>]+)+\s+>\s+(?P.*)') 308 | 309 | 310 | def parse_http_link(indent_level, current_line, matched, source, syntax): 311 | url = matched.group('url') 312 | url_title = matched.group('title') 313 | rt = '<a href="{}">{}</a>'.format(url, url_title) 314 | return rt, indent_level, '', source 315 | 316 | 317 | CUSTOM_PARSERS = [ 318 | (PARSE_HTTP_LINKS_RE, parse_http_link) 319 | ] 320 | 321 | 322 | custom_preprocessor = preprocessor_factory(custom_parsers=CUSTOM_PARSERS, syntax='mako') 323 | 324 | 325 | The ``parse_http_link()`` function is defined according to the strict API. 326 | 327 | Every parser accepts five input arguments: 328 | 329 | 1) ``indent_level`` - an indentation level of the current line. When the parser reaches a line 330 | which indentation is lower or equal to ``indent_level``, it returns control to a top-level function. 331 | 2) ``current_line`` - a line which is being parsed. This is the line that has been matched by 332 | ``matched`` object at the previous parsing step. 333 | 3) ``matched`` - an instance of :class:`re.MatchObject` of the regex associated with the current parser. 334 | 4) ``source`` - an instance of an enumerated object returned by :func:`plim.lexer.enumerate_source`. 335 | 5) ``syntax`` - an instance of one of :class:`plim.syntax.BaseSyntax` children. 336 | 337 | Every parser returns a 4-tuple of: 338 | 339 | 1) parsed_data - a string of successfully parsed data 340 | 2) tail_indent - an indentation level of the ``tail line`` 341 | 3) tail_line - a line which indentation level (``tail_indent``) is lower or equal to 342 | the input ``indent_level``. 343 | 4) ``source`` - an instance of enumerated object returned by :func:`plim.lexer.enumerate_source` 344 | which represents the remaining (untouched) plim markup. 345 | 346 | 347 | From now on, we can use ``custom_preprocessor`` in exactly the same manner as the standard 348 | ``plim.preprocessor``. 349 | 350 | Let's create a plim document with extended syntax: 351 | 352 | .. code-block:: plim 353 | :linenos: 354 | 355 | / hamilton.plim 356 | --------------- 357 | html 358 | head:title Alexander Hamilton 359 | body 360 | h1 Alexander Hamilton 361 | ul 362 | li: http://en.wikipedia.org/wiki/Alexander_Hamilton > Wikipedia Article 363 | li: http://www.amazon.com/Alexander-Hamilton-Ron-Chernow/dp/0143034758 > Full-length Biography 364 | 365 | Here is how we can compile this document into a valid HTML (note the ``-p`` argument): 366 | 367 | .. code-block:: bash 368 | 369 | $ plimc -H -p my_module:custom_preprocessor hamilton.plim 370 | 371 | The result: 372 | 373 | .. code-block:: html 374 | :linenos: 375 | 376 | <html> 377 | <head> 378 | <title>Alexander Hamilton 379 | 380 | 381 |

    Alexander Hamilton

    382 |
    386 | 387 | 388 | -------------------------------------------------------------------------------- /docs/locale/changes.pot: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) 2014, Maxim Avanov 3 | # This file is distributed under the same license as the Plim package. 4 | # FIRST AUTHOR , YEAR. 5 | # 6 | #, fuzzy 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: Plim 0.9\n" 10 | "Report-Msgid-Bugs-To: \n" 11 | "POT-Creation-Date: 2015-06-22 20:43+0800\n" 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 13 | "Last-Translator: FULL NAME \n" 14 | "Language-Team: LANGUAGE \n" 15 | "MIME-Version: 1.0\n" 16 | "Content-Type: text/plain; charset=UTF-8\n" 17 | "Content-Transfer-Encoding: 8bit\n" 18 | 19 | #: ../../CHANGES:2 20 | # 405e69e4dca44c47ad3d9a3ece387f08 21 | msgid "Changelog" 22 | msgstr "" 23 | 24 | #: ../../CHANGES:5 25 | # 18791ca719b046269478b94795b9335f 26 | msgid "Version 0.9" 27 | msgstr "" 28 | 29 | #: ../../CHANGES:7 30 | # 2bf0e406e6234f2ab1db310ee3141d17 31 | msgid "0.9.11" 32 | msgstr "" 33 | 34 | #: ../../CHANGES:9 35 | # 47a221af11ed4050b6f3f93fe0bab533 36 | msgid "Hotfix: Fix incorrect parsing of templates with windows-style newlines (CR+LF)." 37 | msgstr "" 38 | 39 | #: ../../CHANGES:11 40 | # b68df681eea7421da037afaf11559e6b 41 | msgid "0.9.10" 42 | msgstr "" 43 | 44 | #: ../../CHANGES:13 45 | # 8237675f123b4a8dbd998bacee875e2c 46 | msgid "Hotfix: Fix ``plimc``'s inability to find a custom preprocessors module in the current working dir." 47 | msgstr "" 48 | 49 | #: ../../CHANGES:15 50 | # 7e68d3ea5d8243818bbae65b230d1c3b 51 | msgid "0.9.9" 52 | msgstr "" 53 | 54 | #: ../../CHANGES:17 55 | # 49448822ef56435cbaf39d695f41d241 56 | msgid "Hotfix: Fix UnicodeEncodeError in ``-def`` blocks with unicode strings as default argument values." 57 | msgstr "" 58 | 59 | #: ../../CHANGES:19 60 | # 761c614ebff74e1585d163ac2756ee9f 61 | msgid "0.9.8" 62 | msgstr "" 63 | 64 | #: ../../CHANGES:21 65 | # f75441e78f5648e1b1d841a991c3db04 66 | msgid "Change: Stylus extension no longer depends on the ``nib`` package." 67 | msgstr "" 68 | 69 | #: ../../CHANGES:23 70 | # 90ff8801ab414ee4938430035407fd45 71 | msgid "0.9.7" 72 | msgstr "" 73 | 74 | #: ../../CHANGES:25 75 | # 60a7b6fbb8bd4b67b0ebe372b4030281 76 | msgid "Hotfix: Include requirements.txt into the distribution." 77 | msgstr "" 78 | 79 | #: ../../CHANGES:27 80 | # f56fd42871d64de8835d0e7073149247 81 | msgid "0.9.6" 82 | msgstr "" 83 | 84 | #: ../../CHANGES:29 85 | # 4849327746a34090b754444a9d62292a 86 | msgid "Hotfix: Conditional statements parser now can handle strings containing inline tag separator sequences (#27)." 87 | msgstr "" 88 | 89 | #: ../../CHANGES:31 90 | # 29085fcf3e5b4f31895b7da523ccdb3c 91 | msgid "0.9.5" 92 | msgstr "" 93 | 94 | #: ../../CHANGES:33 95 | # ae8a1fe89c60479fa2bfb3f2fb259ae0 96 | msgid "Hotfix: Fix ``plimc`` unicode decoding regression introduced by the previous hotfix." 97 | msgstr "" 98 | 99 | #: ../../CHANGES:36 100 | # c8abee1d489845e2ac3689841b43418c 101 | msgid "0.9.4" 102 | msgstr "" 103 | 104 | #: ../../CHANGES:39 105 | # bb3f81aa24944eb484bc6975c9dd7908 106 | msgid "Hotfix: ``plimc`` no longer crashes with TypeError in Python3 environments" 107 | msgstr "" 108 | 109 | #: ../../CHANGES:39 110 | # 9a8756b3dbb94915b36b03fd479d87fe 111 | msgid "when it writes bytes to sys.stdout." 112 | msgstr "" 113 | 114 | #: ../../CHANGES:41 115 | # be91ff15625d46429d48bab67aad43f3 116 | msgid "0.9.3" 117 | msgstr "" 118 | 119 | #: ../../CHANGES:43 120 | # c4086e1dda1a493ca2edbfa28457c6cd 121 | msgid "Hotfix: Fix UnicodeEncodeError in ``plimc`` when it writes to STDOUT." 122 | msgstr "" 123 | 124 | #: ../../CHANGES:45 125 | # 107633c84d3c4a2c96ed0905c60beb9c 126 | msgid "0.9.2" 127 | msgstr "" 128 | 129 | #: ../../CHANGES:47 130 | # b2d3c45a4ad243a4aa1e8c1f6738c644 131 | msgid "Feature: added support for `Custom Parsers `_." 132 | msgstr "" 133 | 134 | #: ../../CHANGES:49 135 | # f251b74adb0847f1a60c1c383b43db11 136 | msgid "0.9.1" 137 | msgstr "" 138 | 139 | #: ../../CHANGES:51 140 | # 759c717729d94c52a659e237e66668a4 141 | msgid "New Syntax: `New-style Python Blocks `_." 142 | msgstr "" 143 | 144 | #: ../../CHANGES:52 145 | # f54f0236befd4f7da749629365ca992b 146 | msgid "New Syntax: `New-style Module-level Blocks `_." 147 | msgstr "" 148 | 149 | #: ../../CHANGES:55 150 | # d09ba42b47c44ead87ac07a76c50435b 151 | msgid "0.9.0" 152 | msgstr "" 153 | 154 | #: ../../CHANGES:57 155 | # 1bd34af1b6374543a5036cdd2955e443 156 | msgid "Change: Pyramid adapter now relies on Pyramid>=1.5a2 and pyramid_mako>=0.3.1." 157 | msgstr "" 158 | 159 | #: ../../CHANGES:58 160 | # d3faf8c4342740b3bb65a710a502004a 161 | msgid "Change: The package now depends on Mako>=0.9.0." 162 | msgstr "" 163 | 164 | #: ../../CHANGES:59 165 | # 6450211c44d54afa97e1053f97da88a4 166 | msgid "Change: Sass/Scss extension now requires PyScss>=1.2.0.post3." 167 | msgstr "" 168 | 169 | #: ../../CHANGES:61 170 | # 65937435444b4764ba92a00978b3cef1 171 | msgid "Change: Pyramid adapter's ``plim.file_extension`` configuration option is deprecated." 172 | msgstr "" 173 | 174 | #: ../../CHANGES:61 175 | # 9587571d270c4395b43cd1e551062061 176 | msgid "The ``config.add_plim_renderer()`` `directive is provided instead `_." 177 | msgstr "" 178 | 179 | #: ../../CHANGES:64 180 | # eb5b35e47aa14dd5bf5b1105f583437a 181 | msgid "Version 0.8" 182 | msgstr "" 183 | 184 | #: ../../CHANGES:66 185 | # 1548398201ba4ecead5951fdd3c8389f 186 | msgid "0.8.9" 187 | msgstr "" 188 | 189 | #: ../../CHANGES:68 190 | # ed6300cffc5f498492e9334b9df0c75a 191 | msgid "Bugfix: Use sys.maxsize instead of unavailable sys.maxint on Python 3." 192 | msgstr "" 193 | 194 | #: ../../CHANGES:70 195 | # e555f9bc2c144f498fe057c8aaee6a68 196 | msgid "0.8.8" 197 | msgstr "" 198 | 199 | #: ../../CHANGES:72 200 | # 9c13df7fb16c4038a91e08cab30eaad8 201 | msgid "Hotfix: Make Plim working with a development version of pyScss for Python-3.x setups." 202 | msgstr "" 203 | 204 | #: ../../CHANGES:74 205 | # 3dcb47f33ffa4c1eae88f5f7ccc68cb0 206 | msgid "0.8.7" 207 | msgstr "" 208 | 209 | #: ../../CHANGES:76 210 | # 70c767d2c48f40cc8984670480eb539b 211 | msgid "Bugfix: Pyramid adapter is now compatible with the 1.5a2+ version of the framework." 212 | msgstr "" 213 | 214 | #: ../../CHANGES:78 215 | # b5688ef4dbdc47628699672c4bdaa7d7 216 | msgid "Change: `default template file extension `_" 217 | msgstr "" 218 | 219 | #: ../../CHANGES:78 220 | # 308678513b3b461da29750a1849230f5 221 | msgid "used in pyramid bindings is changed from \".plm\" to \".plim\"." 222 | msgstr "" 223 | 224 | #: ../../CHANGES:80 225 | # e68fa20099cc42fba3c424f0698e0c76 226 | msgid "0.8.6" 227 | msgstr "" 228 | 229 | #: ../../CHANGES:82 230 | # ec6b93743a0f4e28aa91906d52843859 231 | msgid "Hotfix: fixed assertion error in handlebars parser." 232 | msgstr "" 233 | 234 | #: ../../CHANGES:84 235 | # e3f60b61b32c4ffa9890742ccdbf64b5 236 | msgid "0.8.5" 237 | msgstr "" 238 | 239 | #: ../../CHANGES:86 240 | # f2f351083f3b40c79c3d8f5aeca86417 241 | msgid "Feature: added support for `Handlebars blocks `_." 242 | msgstr "" 243 | 244 | #: ../../CHANGES:88 245 | # 5c4bb2298d634f899101c36a154b5449 246 | msgid "0.8.4" 247 | msgstr "" 248 | 249 | #: ../../CHANGES:90 250 | # 5b8713857b144127b42ae76eb71aafff 251 | msgid "Hotfix: updated links to github." 252 | msgstr "" 253 | 254 | #: ../../CHANGES:92 255 | # 7e4274da77914482acf7fd4c8b46a913 256 | msgid "0.8.3" 257 | msgstr "" 258 | 259 | #: ../../CHANGES:94 260 | # 49a25baec0094aa2a019d05a34d2f85d 261 | msgid "Hotfix: prevent lexer from parsing embedded markup inside ``style`` and ``script`` blocks." 262 | msgstr "" 263 | 264 | #: ../../CHANGES:96 265 | # 94480f9b84d9481290bed756a80c94bf 266 | msgid "0.8.2" 267 | msgstr "" 268 | 269 | #: ../../CHANGES:98 270 | # 3e7c5e8e06fd44bb95e564ad89e93ad2 271 | msgid "Feature: added support for `Embedded Markup `_." 272 | msgstr "" 273 | 274 | #: ../../CHANGES:99 275 | # 56806c50cda64dc6b5a7bfab72f932b0 276 | msgid "Feature: plimc utility is now able to output plain HTML." 277 | msgstr "" 278 | 279 | #: ../../CHANGES:101 280 | # d8d2941495d7466b8eb1ca63d0b8fd16 281 | msgid "0.8.1" 282 | msgstr "" 283 | 284 | #: ../../CHANGES:103 285 | # 6d5a42a60e9f42b4a0330182d13283b1 286 | msgid "Feature: added support for `Inline Statements `_." 287 | msgstr "" 288 | 289 | #: ../../CHANGES:105 290 | # 4e92bbaa7dc447baabd2f5f2d532484c 291 | msgid "0.8.0" 292 | msgstr "" 293 | 294 | #: ../../CHANGES:107 295 | # 72f3b91ad1824889b9ba9ba3451dac7c 296 | msgid "Feature: added support for dynamic attributes unpacker (an equivalent to Slim's splat attributes)." 297 | msgstr "" 298 | 299 | #: ../../CHANGES:111 300 | # 98d3a11b11af4cfda26175b3c2fc665b 301 | msgid "Version 0.7" 302 | msgstr "" 303 | 304 | #: ../../CHANGES:113 305 | # 12ed82447bc4451a98d532ed214a6659 306 | msgid "0.7.14" 307 | msgstr "" 308 | 309 | #: ../../CHANGES:115 310 | # 0990d54b0b684f54ae4806e97d29ada1 311 | msgid "Hotfix: fixed bug with unicode handling." 312 | msgstr "" 313 | 314 | #: ../../CHANGES:117 315 | # 0ef0a445215349c384f5d9e06d48d247 316 | msgid "0.7.13" 317 | msgstr "" 318 | 319 | #: ../../CHANGES:119 320 | # 374c8fd5163e4fc3b809fee6250cade2 321 | msgid "Hotfix: fixed bug with static unicode attributes." 322 | msgstr "" 323 | 324 | #: ../../CHANGES:121 325 | # b32cffa1f51541a4963ce393a32b56f5 326 | msgid "0.7.12" 327 | msgstr "" 328 | 329 | #: ../../CHANGES:123 330 | # f7d9f1a852694cd799fa89d89cdec00c 331 | msgid "Unnecessary newline characters at the end of literal blocks have been removed." 332 | msgstr "" 333 | 334 | #: ../../CHANGES:124 335 | # c813e7205c364c4e8223dc7ca6258474 336 | msgid "Added the command-line tool ``plimc``." 337 | msgstr "" 338 | 339 | #: ../../CHANGES:126 340 | # 62ff7aca6ae64ddd8a075161f4cac478 341 | msgid "0.7.11" 342 | msgstr "" 343 | 344 | #: ../../CHANGES:128 345 | # f3f685f2fff64711942a34bcf50e306e 346 | msgid "Fixed bug that had to do with incorrect parsing of multi-line dynamic class attributes." 347 | msgstr "" 348 | 349 | #: ../../CHANGES:129 350 | # 3f7fa02b30f04ce1a6484843d33bb1c4 351 | msgid "Fixed bug that had to do with passing incorrect data to plim parser in babel adapter." 352 | msgstr "" 353 | 354 | #: ../../CHANGES:131 355 | # 86619c2663e343f0bf9687bceb7d0207 356 | msgid "0.7.10 Fixed bug with unicode error in python block. Thanks to sqrabs@github!" 357 | msgstr "" 358 | 359 | #: ../../CHANGES:134 360 | # 7f34aef900444fe69b5d1188c53b65f5 361 | msgid "0.7.9 Added babel message extraction plugin." 362 | msgstr "" 363 | 364 | #: ../../CHANGES:137 365 | # 5a9dacc2d7554ac8912ad06c74d274f4 366 | msgid "0.7.8 Expanded range of possible numeric values that don't require double-quoting." 367 | msgstr "" 368 | 369 | #: ../../CHANGES:140 370 | # 423c20aa8f9744d2b90fc5d524dbc2ab 371 | msgid "0.7.7" 372 | msgstr "" 373 | 374 | #: ../../CHANGES:142 375 | # f5ed7b13529946bcb19bdaf830f0f900 376 | msgid "Fixed bug with linebreaks without trailing newline character." 377 | msgstr "" 378 | 379 | #: ../../CHANGES:143 380 | # 54282822160c4989b6e1fef484bb115e 381 | msgid "Fixed bug with missing explicit whitespace after ``=,`` and ``==,`` line indicators." 382 | msgstr "" 383 | 384 | #: ../../CHANGES:145 385 | # 309a34950d3f43f280704eb8268cb3a2 386 | msgid "0.7.6 Fixed bug with incorrect parsing of static boolean attributes." 387 | msgstr "" 388 | 389 | #: ../../CHANGES:148 390 | # 153e0947846b49c48270234109113242 391 | msgid "0.7.5 Fixed bug with comment and content blocks separated by empty lines." 392 | msgstr "" 393 | 394 | #: ../../CHANGES:151 395 | # 085c8ff2b7e44618b460e0ce3ea870be 396 | msgid "0.7.4 Added -stylus extension." 397 | msgstr "" 398 | 399 | #: ../../CHANGES:154 400 | # 97ef0878ec0f4aa6b2b923c4dbdb7a6b 401 | msgid "0.7.3 Fix bug with literal one-liners." 402 | msgstr "" 403 | 404 | #: ../../CHANGES:157 405 | # 68f272604dfc438dbb78407fadf8f109 406 | msgid "0.7.1 Fixed installation error caused by missing README.rst." 407 | msgstr "" 408 | 409 | #: ../../CHANGES:160 410 | # 813cb6acd2f24af98e5da086d7e6c2d0 411 | msgid "0.7.0 Initial public release." 412 | msgstr "" 413 | 414 | -------------------------------------------------------------------------------- /tests/fixtures/reST_result.mako: -------------------------------------------------------------------------------- 1 |
    2 |

    The reStructuredText Cheat Sheet: Syntax Reminders

    3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
    Info:See <http://docutils.sf.net/rst.html> for introductory docs.
    Author:David Goodger <goodger@python.org>
    Date:2011-06-17
    Revision:7056
    Description:This is a "docinfo block", or bibliographic field list
    19 |
    20 |

    Section Structure

    21 |

    Section titles are underlined or overlined & underlined.

    22 |
    23 |
    24 |

    Body Elements

    25 |

    Grid table:

    26 | 27 | 28 | 29 | 30 | 31 | 32 | 37 | 46 | 47 | 52 | 53 | 61 | 62 | 63 |

    Paragraphs are flush-left, 33 | separated by blank lines.

    34 |
    35 | Block quotes are indented.
    36 |

    Literal block, preceded by "::":

    38 |
     39 | Indented
     40 | 
    41 |

    or:

    42 |
     43 | > Quoted
     44 | 
    45 |
     48 | >>> print 'Doctest block'
     49 | Doctest block
     50 | 
    51 |
    54 |
    Line blocks preserve line breaks & indents. [new in 0.3.6]
    55 |
    56 |
    Useful for addresses, verse, and adornment-free lists; long 57 | lines can be wrapped with continuation lines.
    58 |
    59 |
    60 |
    64 |

    Simple tables:

    65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 81 | 82 | 83 | 88 | 89 | 90 | 95 | 96 | 97 | 106 | 107 | 108 | 118 | 119 | 120 |
    List TypeExamples
    Bullet list
      78 |
    • items begin with "-", "+", or "*"
    • 79 |
    80 |
    Enumerated list
      84 |
    1. items use any variation of "1.", "A)", and "(i)"
    2. 85 |
    3. also auto-enumerated
    4. 86 |
    87 |
    Definition list
    91 |
    Term is flush-left : optional classifier
    92 |
    Definition is indented, no blank line between
    93 |
    94 |
    Field list 98 | 99 | 100 | 101 | 102 | 103 | 104 |
    field name:field body
    105 |
    Option list 109 | 110 | 111 | 112 | 114 | 115 | 116 |
    113 | -oat least 2 spaces between option & description
    117 |
    121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 141 | 142 | 143 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 160 | 161 | 162 | 163 | 164 | 165 | 167 | 168 | 169 | 171 | 172 | 173 |
    Explicit MarkupExamples (visible in the text source)
    Footnote 134 | 135 | 136 | 138 | 139 |
    [1]Manually numbered or [#] auto-numbered 137 | (even [#labelled]) or [*] auto-symbol
    140 |
    Citation 144 | 145 | 146 | 147 | 148 |
    [CIT2002]A citation.
    149 |
    Hyperlink Target
    Anonymous Target
    Directive ("::")images/biohazard.png 159 |
    Substitution Def
    Comment 166 |
    Empty Comment(".." on a line by itself, with blank lines before & after, 170 | used to separate indentation contexts)
    174 |
    175 |
    176 |

    Inline Markup

    177 |

    emphasis; strong emphasis; interpreted text; interpreted text 178 | with role; inline literal text; standalone hyperlink, 179 | http://docutils.sourceforge.net; named reference, reStructuredText; 180 | anonymous reference; footnote reference, [1]; citation reference, 181 | [CIT2002]; like an inline directive; inline internal target.

    182 |
    183 |
    184 |

    Directive Quick Reference

    185 |

    See <http://docutils.sf.net/docs/ref/rst/directives.html> for full info.

    186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 |
    Directive NameDescription (Docutils version added to, in [brackets])
    attentionSpecific admonition; also "caution", "danger", 199 | "error", "hint", "important", "note", "tip", "warning"
    admonitionGeneric titled admonition: .. admonition:: By The Way
    image.. image:: picture.png; many options possible
    figureLike "image", but with optional caption and legend
    topic.. topic:: Title; like a mini section
    sidebar.. sidebar:: Title; like a mini parallel document
    parsed-literalA literal block with parsed inline markup
    rubric.. rubric:: Informal Heading
    epigraphBlock quote with class="epigraph"
    highlightsBlock quote with class="highlights"
    pull-quoteBlock quote with class="pull-quote"
    compoundCompound paragraphs [0.3.6]
    containerGeneric block-level container element [0.3.10]
    tableCreate a titled table [0.3.1]
    list-tableCreate a table from a uniform two-level bullet list [0.3.8]
    csv-tableCreate a table from CSV data (requires Python 2.3+) [0.3.4]
    contentsGenerate a table of contents
    sectnumAutomatically number sections, subsections, etc.
    header, footerCreate document decorations [0.3.8]
    target-notesCreate an explicit footnote for each external target
    mathMathematical notation (input in LaTeX format)
    metaHTML-specific metadata
    includeRead an external reST file as if it were inline
    rawNon-reST data passed untouched to the Writer
    replaceReplacement text for substitution definitions
    unicodeUnicode character code conversion for substitution defs
    dateGenerates today's date; for substitution defs
    classSet a "class" attribute on the next element
    roleCreate a custom interpreted text role [0.3.2]
    default-roleSet the default interpreted text role [0.3.10]
    titleSet the metadata document title [0.3.10]
    293 |
    294 |
    295 |

    Interpreted Text Role Quick Reference

    296 |

    See <http://docutils.sf.net/docs/ref/rst/roles.html> for full info.

    297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 |
    Role NameDescription
    emphasisEquivalent to emphasis
    literalEquivalent to literal but processes backslash escapes
    mathMathematical notation (input in LaTeX format)
    PEPReference to a numbered Python Enhancement Proposal
    RFCReference to a numbered Internet Request For Comments
    rawFor non-reST data; cannot be used directly (see docs) [0.3.6]
    strongEquivalent to strong
    subSubscript
    supSuperscript
    titleTitle reference (book, etc.); standard default role
    340 |
    341 |
    --------------------------------------------------------------------------------