示例#1
0
    def test_run_with_default_opts(self):
        content = parser('''\
asd
---

.. blohg-attachmentimage:: foo.jpg
''', 3)
        self.url_for.assert_called_once_with('attachments', filename='foo.jpg',
                                             _external=True)
        self.assertIn('http://lol/foo.jpg', content['images'])
        self.assertIn('src="http://lol/foo.jpg"', content['fragment'])
示例#2
0
    def test_run_with_default_opts(self):
        content = parser('''\
asd
---

.. blohg-attachmentimage:: foo.jpg
''', 3)
        self.url_for.assert_called_once_with('attachments', filename='foo.jpg',
                                             _external=True)
        self.assertIn('http://lol/foo.jpg', content['images'])
        self.assertIn('src="http://lol/foo.jpg"', content['fragment'])
示例#3
0
    def test_simple_include(self):
        content = parser('''\
asd
===

hahah

.. blohg-includehg:: content/foo.rst
''', 3)
        self.assertIn('<h3>Included paragraph</h3>', content['fragment'])
        self.assertIn('<p>lol</p>', content['fragment'])
        self.assertIn('<p>XD</p>', content['fragment'])
示例#4
0
    def test_simple_include(self):
        content = parser('''\
asd
===

hahah

.. blohg-includehg:: content/foo.rst
''', 3)
        self.assertIn('<h3>Included paragraph</h3>', content['fragment'])
        self.assertIn('<p>lol</p>', content['fragment'])
        self.assertIn('<p>XD</p>', content['fragment'])
示例#5
0
    def test_include_literal(self):
        content = parser('''\
asd
===

hahah

.. blohg-includehg:: content/foo.rst
   :literal:
''', 3)
        self.assertIn('\nIncluded paragraph\n', content['fragment'])
        self.assertIn('\nlol\n', content['fragment'])
        self.assertIn('\nXD\n', content['fragment'])
示例#6
0
    def test_include_literal(self):
        content = parser('''\
asd
===

hahah

.. blohg-includehg:: content/foo.rst
   :literal:
''', 3)
        self.assertIn('\nIncluded paragraph\n', content['fragment'])
        self.assertIn('\nlol\n', content['fragment'])
        self.assertIn('\nXD\n', content['fragment'])
示例#7
0
    def test_run_with_default_opts(self):
        content = parser('''\
asd
---

.. blohg-vimeo:: 34368016
''', 3)
        self.assertIn('http://player.vimeo.com/video/34368016',
                      content['fragment'])
        self.assertIn('width: 425px', content['fragment'])
        self.assertIn('height: 344px', content['fragment'])
        self.assertIn('align-center', content['fragment'])
        self.assertIn('frameborder="0"', content['fragment'])
        self.assertIn('allowfullscreen', content['fragment'])
示例#8
0
    def test_run_with_default_opts(self):
        content = parser('''\
asd
---

.. blohg-youtube:: ssMfQ9ybTEc
''', 3)
        self.assertIn('http://www.youtube.com/embed/ssMfQ9ybTEc',
                      content['fragment'])
        self.assertIn('width: 425px', content['fragment'])
        self.assertIn('height: 344px', content['fragment'])
        self.assertIn('align-center', content['fragment'])
        self.assertIn('frameborder="0"', content['fragment'])
        self.assertIn('allowfullscreen', content['fragment'])
示例#9
0
    def test_run_with_default_opts(self):
        content = parser('''\
asd
---

.. blohg-sourcecode:: python

    import os

    print os.path

''', 3)
        self.assertIn('class="highlight"', content['fragment'])
        self.assertIn('import', content['fragment'])
示例#10
0
    def test_run_with_default_opts(self):
        content = parser('''\
asd
---

.. blohg-math::

   \\frac{x^2}{1+x}
''', 3)
        self.assertIn('https://chart.googleapis.com/chart?cht=tx&chl='
                      '%5Cfrac%7Bx%5E2%7D%7B1%2Bx%7D', content['images'])
        self.assertIn('https://chart.googleapis.com/chart?cht=tx&amp;'
                      'chl=%5Cfrac%7Bx%5E2%7D%7B1%2Bx%7D', content['fragment'])
        self.assertIn('align-center', content['fragment'])
示例#11
0
    def test_run_with_default_opts(self):
        content = parser('''\
asd
---

.. blohg-vimeo:: 34368016
''', 3)
        self.assertIn('http://player.vimeo.com/video/34368016',
                      content['fragment'])
        self.assertIn('width: 425px', content['fragment'])
        self.assertIn('height: 344px', content['fragment'])
        self.assertIn('align-center', content['fragment'])
        self.assertIn('frameborder="0"', content['fragment'])
        self.assertIn('allowfullscreen', content['fragment'])
示例#12
0
    def test_run_with_default_opts(self):
        content = parser('''\
asd
---

.. blohg-math::

   \\frac{x^2}{1+x}
''', 3)
        self.assertIn('https://chart.googleapis.com/chart?cht=tx&chl='
                      '%5Cfrac%7Bx%5E2%7D%7B1%2Bx%7D', content['images'])
        self.assertIn('https://chart.googleapis.com/chart?cht=tx&amp;'
                      'chl=%5Cfrac%7Bx%5E2%7D%7B1%2Bx%7D', content['fragment'])
        self.assertIn('align-center', content['fragment'])
示例#13
0
    def test_run_with_default_opts(self):
        content = parser('''\
asd
---

.. blohg-sourcecode:: python

    import os

    print os.path

''', 3)
        self.assertIn('class="highlight"', content['fragment'])
        self.assertIn('import', content['fragment'])
示例#14
0
    def test_run_with_default_opts(self):
        content = parser('''\
asd
---

.. blohg-youtube:: ssMfQ9ybTEc
''', 3)
        self.assertIn('http://www.youtube.com/embed/ssMfQ9ybTEc',
                      content['fragment'])
        self.assertIn('width: 425px', content['fragment'])
        self.assertIn('height: 344px', content['fragment'])
        self.assertIn('align-center', content['fragment'])
        self.assertIn('frameborder="0"', content['fragment'])
        self.assertIn('allowfullscreen', content['fragment'])
示例#15
0
    def test_include_with_start_and_end(self):
        content = parser('''\
asd
===

hahah

.. blohg-includehg:: content/foo.rst
   :start-line: 3
   :end-line: 4
''', 3)
        self.assertNotIn('<h3>Included paragraph</h3>', content['fragment'])
        self.assertIn('<p>lol</p>', content['fragment'])
        self.assertNotIn('<p>XD</p>', content['fragment'])
示例#16
0
    def test_include_with_start_and_end(self):
        content = parser('''\
asd
===

hahah

.. blohg-includehg:: content/foo.rst
   :start-line: 3
   :end-line: 4
''', 3)
        self.assertNotIn('<h3>Included paragraph</h3>', content['fragment'])
        self.assertIn('<p>lol</p>', content['fragment'])
        self.assertNotIn('<p>XD</p>', content['fragment'])
示例#17
0
    def test_run_with_argument_for_subsubpage(self):
        content = parser('''\
asd
---

.. blohg-subpages:: foo/bar
''', 3)
        self.assertNotIn('"/foo/"', content['fragment'])
        self.assertNotIn('>Foo :)<', content['fragment'])
        self.assertNotIn('"/bar/"', content['fragment'])
        self.assertNotIn('>Bar!<', content['fragment'])
        self.assertNotIn('"/foo/bar/"', content['fragment'])
        self.assertNotIn('>Foo Bar :P<', content['fragment'])
        self.assertIn('"/foo/bar/baz/"', content['fragment'])
        self.assertIn('>Foo Bar Baz XD<', content['fragment'])
示例#18
0
    def test_run_with_argument_from_subpage(self):
        content = parser('''\
asd
---

.. blohg-subpages:: foo
''', 3, ':repo:cont/foo/index.rs')
        self.assertNotIn('"/foo/"', content['fragment'])
        self.assertNotIn('>Foo :)<', content['fragment'])
        self.assertNotIn('"/bar/"', content['fragment'])
        self.assertNotIn('>Bar!<', content['fragment'])
        self.assertIn('"/foo/bar/"', content['fragment'])
        self.assertIn('>Foo Bar :P<', content['fragment'])
        self.assertNotIn('"/foo/bar/baz/"', content['fragment'])
        self.assertNotIn('>Foo Bar Baz XD<', content['fragment'])
示例#19
0
    def test_run(self):
        content = parser('''\
asd
---

.. blohg-sourcecode:: python
   :linenos:

    import os

    print os.path

''', 3)
        self.assertIn('class="lineno">3', content['fragment'])
        self.assertIn('import', content['fragment'])
示例#20
0
    def test_run_with_argument_from_subpage(self):
        content = parser('''\
asd
---

.. blohg-subpages:: foo
''', 3, ':repo:cont/foo/index.rs')
        self.assertNotIn('"/foo/"', content['fragment'])
        self.assertNotIn('>Foo :)<', content['fragment'])
        self.assertNotIn('"/bar/"', content['fragment'])
        self.assertNotIn('>Bar!<', content['fragment'])
        self.assertIn('"/foo/bar/"', content['fragment'])
        self.assertIn('>Foo Bar :P<', content['fragment'])
        self.assertNotIn('"/foo/bar/baz/"', content['fragment'])
        self.assertNotIn('>Foo Bar Baz XD<', content['fragment'])
示例#21
0
    def test_run(self):
        content = parser('''\
asd
---

.. blohg-sourcecode:: python
   :linenos:

    import os

    print os.path

''', 3)
        self.assertIn('class="lineno">3', content['fragment'])
        self.assertIn('import', content['fragment'])
示例#22
0
    def test_run(self):
        content = parser('''\
asd
---

.. blohg-attachmentfigure:: foo.jpg
   :align: left

   asdf lol.

''', 3)
        self.url_for.assert_called_once_with('attachments', filename='foo.jpg',
                                             _external=True)
        self.assertIn('http://lol/foo.jpg', content['images'])
        self.assertIn('src="http://lol/foo.jpg"', content['fragment'])
        self.assertIn('caption">asdf lol.', content['fragment'])
        self.assertIn('align-left', content['fragment'])
示例#23
0
    def test_run(self):
        content = parser('''\
asd
---

.. blohg-attachmentfigure:: foo.jpg
   :align: left

   asdf lol.

''', 3)
        self.url_for.assert_called_once_with('attachments', filename='foo.jpg',
                                             _external=True)
        self.assertIn('http://lol/foo.jpg', content['images'])
        self.assertIn('src="http://lol/foo.jpg"', content['fragment'])
        self.assertIn('caption">asdf lol.', content['fragment'])
        self.assertIn('align-left', content['fragment'])
示例#24
0
    def test_run_with_argument_for_subsubpage(self):
        content = parser('''\
asd
---

.. blohg-subpages:: foo/bar
''', 3)
        self.assertNotIn('"/foo/"', content['fragment'])
        self.assertNotIn('>Foo :)<', content['fragment'])
        self.assertNotIn('"/bar/"', content['fragment'])
        self.assertNotIn('>Bar!<', content['fragment'])
        self.assertNotIn('"/foo/bar/"', content['fragment'])
        self.assertNotIn('>Foo Bar :P<', content['fragment'])
        self.assertIn('"/foo/bar/baz/"', content['fragment'])
        self.assertIn('>Foo Bar Baz XD<', content['fragment'])
        self.assertNotIn('>Foo Bar Bad XD<', content['fragment'])
        self.assertIn('"/foo/bar/bad/"', content['fragment'])
        self.assertIn('###asd###', content['fragment'])
示例#25
0
    def test_run(self):
        content = parser('''\
asd
---

.. blohg-vimeo:: 34368016
   :align: left
   :width: 100
   :height: 200
   :allowfullscreen: false
   :border: 1
''', 3)
        self.assertIn('http://player.vimeo.com/video/34368016',
                      content['fragment'])
        self.assertIn('width: 100px', content['fragment'])
        self.assertIn('height: 200px', content['fragment'])
        self.assertIn('align-left', content['fragment'])
        self.assertIn('frameborder="1"', content['fragment'])
        self.assertNotIn('allowfullscreen', content['fragment'])
示例#26
0
    def test_run(self):
        content = parser('''\
asd
---

.. blohg-youtube:: ssMfQ9ybTEc
   :align: left
   :width: 100
   :height: 200
   :allowfullscreen: false
   :border: 1
''', 3)
        self.assertIn('http://www.youtube.com/embed/ssMfQ9ybTEc',
                      content['fragment'])
        self.assertIn('width: 100px', content['fragment'])
        self.assertIn('height: 200px', content['fragment'])
        self.assertIn('align-left', content['fragment'])
        self.assertIn('frameborder="1"', content['fragment'])
        self.assertNotIn('allowfullscreen', content['fragment'])
示例#27
0
    def test_run(self):
        content = parser('''\
asd
---

.. blohg-youtube:: ssMfQ9ybTEc
   :align: left
   :width: 100
   :height: 200
   :allowfullscreen: false
   :border: 1
''', 3)
        self.assertIn('http://www.youtube.com/embed/ssMfQ9ybTEc',
                      content['fragment'])
        self.assertIn('width: 100px', content['fragment'])
        self.assertIn('height: 200px', content['fragment'])
        self.assertIn('align-left', content['fragment'])
        self.assertIn('frameborder="1"', content['fragment'])
        self.assertNotIn('allowfullscreen', content['fragment'])
示例#28
0
    def test_run(self):
        content = parser('''\
asd
---

.. blohg-vimeo:: 34368016
   :align: left
   :width: 100
   :height: 200
   :allowfullscreen: false
   :border: 1
''', 3)
        self.assertIn('http://player.vimeo.com/video/34368016',
                      content['fragment'])
        self.assertIn('width: 100px', content['fragment'])
        self.assertIn('height: 200px', content['fragment'])
        self.assertIn('align-left', content['fragment'])
        self.assertIn('frameborder="1"', content['fragment'])
        self.assertNotIn('allowfullscreen', content['fragment'])
示例#29
0
文件: models.py 项目: RMCampos/blohg
 def parsed_source(self):
     return parser(self.full, self._rst_header_level,
                   ':repo:%s' % self.path)
示例#30
0
文件: models.py 项目: liuyxpp/blohg
 def parsed_abstract(self):
     if not self.read_more:
         return self.parsed_source
     return parser(self.abstract, self._rst_header_level,
                   ':repo:%s' % self.path)
示例#31
0
文件: models.py 项目: RMCampos/blohg
 def parsed_abstract(self):
     if not self.read_more:
         return self.parsed_source
     return parser(self.abstract, self._rst_header_level,
                   ':repo:%s' % self.path)
示例#32
0
文件: models.py 项目: liuyxpp/blohg
 def parsed_source(self):
     return parser(self.full, self._rst_header_level,
                   ':repo:%s' % self.path)