Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
03cd3b27
Commit
03cd3b27
authored
Mar 13, 2006
by
Andreas Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replace docutils code with some similiar code taken
from zope.app.renderer.rest
parent
7107e3df
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
52 deletions
+23
-52
lib/python/Products/ZReST/ZReST.py
lib/python/Products/ZReST/ZReST.py
+23
-52
No files found.
lib/python/Products/ZReST/ZReST.py
View file @
03cd3b27
...
@@ -7,19 +7,22 @@ This Product stores two texts - a "source" text in ReStructureText format,
...
@@ -7,19 +7,22 @@ This Product stores two texts - a "source" text in ReStructureText format,
and a HTML "formatted" version of that text.
and a HTML "formatted" version of that text.
'''
'''
import
sys
import
docutils.core
,
docutils
.
io
import
docutils.core
,
docutils
.
io
from
docutils.writers.html4css1
import
HTMLTranslator
,
Writer
from
Globals
import
InitializeClass
,
DTMLFile
from
Acquisition
import
Implicit
from
Persistence
import
Persistent
from
OFS.SimpleItem
import
Item
from
OFS.SimpleItem
import
Item
from
OFS.PropertyManager
import
PropertyManager
from
OFS.PropertyManager
import
PropertyManager
from
OFS.History
import
Historical
,
html_diff
from
OFS.History
import
Historical
,
html_diff
from
Acquisition
import
Implicit
from
Globals
import
InitializeClass
,
DTMLFile
from
Persistence
import
Persistent
from
AccessControl
import
ClassSecurityInfo
from
AccessControl
import
ClassSecurityInfo
from
AccessControl
import
ModuleSecurityInfo
from
AccessControl
import
ModuleSecurityInfo
from
DateTime.DateTime
import
DateTime
from
DateTime.DateTime
import
DateTime
from
App.config
import
getConfiguration
from
App.config
import
getConfiguration
import
sys
modulesecurity
=
ModuleSecurityInfo
()
modulesecurity
=
ModuleSecurityInfo
()
modulesecurity
.
declareProtected
(
'View management screens'
,
modulesecurity
.
declareProtected
(
'View management screens'
,
...
@@ -190,55 +193,23 @@ class ZReST(Item, PropertyManager, Historical, Implicit, Persistent):
...
@@ -190,55 +193,23 @@ class ZReST(Item, PropertyManager, Historical, Implicit, Persistent):
''' Render the source to HTML
''' Render the source to HTML
'''
'''
if
self
.
_v_formatted
is
None
:
if
self
.
_v_formatted
is
None
:
# format with strings
pub
=
docutils
.
core
.
Publisher
()
pub
.
set_reader
(
'standalone'
,
None
,
'restructuredtext'
)
pub
.
set_writer
(
'html'
)
# go with the defaults
pub
.
get_settings
()
# this is needed, but doesn't seem to do anything
pub
.
settings
.
_destination
=
''
# use the stylesheet chosen by the user
settings
=
{
pub
.
settings
.
stylesheet
=
self
.
stylesheet
'halt_level'
:
6
,
'report_level'
:
self
.
report_level
,
# set the reporting level to something sane
'input_encoding'
:
self
.
input_encoding
,
pub
.
settings
.
report_level
=
int
(
self
.
report_level
)
'output_encoding'
:
self
.
output_encoding
,
'initial_header_level'
:
1
,
# disallow use of the .. include directive for security reasons
'stylesheet'
:
self
.
stylesheet
,
pub
.
settings
.
file_insertion_enabled
=
0
'pub.settings.warning_stream'
:
Warnings
(),
'file_insertion_enabled'
:
0
,
# don't break if we get errors
}
pub
.
settings
.
halt_level
=
6
# remember warnings
pub
.
settings
.
warning_stream
=
Warnings
()
pub
.
source
=
docutils
.
io
.
StringInput
(
source
=
self
.
source
,
encoding
=
self
.
input_encoding
)
# output - not that it's needed
pub
.
settings
.
output_encoding
=
self
.
output_encoding
pub
.
destination
=
docutils
.
io
.
StringOutput
(
encoding
=
self
.
output_encoding
)
# parse!
document
=
pub
.
reader
.
read
(
pub
.
source
,
pub
.
parser
,
pub
.
settings
)
# transform
pub
.
apply_transforms
(
document
)
self
.
_v_warnings
=
''
.
join
(
pub
.
settings
.
warning_stream
.
messages
)
if
document
.
children
:
item
=
document
.
children
[
0
]
if
item
.
tagname
==
'title'
:
self
.
title
=
item
.
children
[
0
].
astext
()
# do the format
self
.
_v_formatted
=
docutils
.
core
.
publish_string
(
self
.
_v_formatted
=
pub
.
writer
.
write
(
document
,
pub
.
destination
)
self
.
source
,
writer
=
Writer
(),
settings_overrides
=
settings
,
)
return
self
.
_v_formatted
return
self
.
_v_formatted
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment