0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ReTextを使ってreStructuredTextで書いたときタイトルとサブタイトルが入らない

Last updated at Posted at 2015-02-17

ReTextを使ってreStructuredTextで書いたときレンダリング結果にタイトルとサブタイトルが入らない。

ReText-3.X までは wpgen を修正する。

diff -u wpgen/wpgen.py wpgen/wpgen.py
--- wpgen/wpgen.py     2012-04-22 23:52:07.000000000 +0900
+++ wpgen/wpgen.py     2012-04-27 22:00:58.000000000 +0900
@@ -108,7 +109,8 @@
                     pass
           elif ext in (".rst", ".rest") and use_docutils:
                parts = publish_parts(text, writer_name='html')
-               html = parts['body']
+               #html = parts['body']
+               html = parts['html_body']
                if parts['title']:
                     pagename = parts['title']
           elif ext in (".htm", ".html") and bn != "template":

ReText-4.0 以降は、Markups を使うようになったので、HTML の body の取り出し方を変えるには、ReText ではなく Markups の方を変更する必要がある。もしかすると変更による副作用があるかもしれない。

--- markups/restructuredtext.py-	2014-07-23 19:32:40.000000000 +0900
+++ markups/restructuredtext.py	2015-02-17 21:53:02.000000000 +0900
@@ -53,7 +53,8 @@
 		return self.publish_parts(text)['title']
 
 	def get_document_body(self, text):
-		return self.publish_parts(text)['body']
+		#return self.publish_parts(text)['body']
+		return self.publish_parts(text)['html_body']
 
 	def get_stylesheet(self, text=''):
 		origstyle = self.publish_parts(text)['stylesheet']
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?