Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fails to parse \input{...}% #28

Closed
johnyf opened this issue Jul 17, 2014 · 3 comments
Closed

fails to parse \input{...}% #28

johnyf opened this issue Jul 17, 2014 · 3 comments
Assignees
Milestone

Comments

@johnyf
Copy link
Contributor

johnyf commented Jul 17, 2014

dot2tex fails if called from dot2texi with an input file containing \input{...}% instead of \input{...}. The problem is due to failure to parse the % sign. This issue exists in v2.9.0 and in 254cb27.

Details below:

The code:

\documentclass[10pt,xetex]{beamer}

\usepackage[no-math]{fontspec}
\usepackage{xunicode,xltxtra}
\defaultfontfeatures{Mapping=tex-text}

\usepackage[tikz,debug]{dot2texi}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}

\begin{document}

\begin{frame}[fragile]
    \begin{dot2tex}[]
        \input{0.dot}
    \end{dot2tex}
\end{frame}

\end{document}

fails, whereas removing the % from after \input succeeds:

\begin{frame}[fragile]
    \begin{dot2tex}[styleonly,dot,mathmode,scale=0.6]
        \input{0.dot}
    \end{dot2tex}
\end{frame}

The cause I have identified up to now is output \input{0.dot}% to the auxiliary dot file created, then dot2tex fails to parse the line \input{0.dot}% in that file.

The dot2tex.log contents are:

2014-07-17 00:28:31,685 dot2tex INFO ------- Start of run -------
2014-07-17 00:28:31,685 dot2tex INFO Dot2tex version 2.9.0
2014-07-17 00:28:31,697 dot2tex INFO System information:
  Python: sys.version_info(major=2, minor=7, micro=8, releaselevel='final', serial=0) 
  Platform: Darwin-12.5.0-x86_64-i386-64bit
  Pyparsing: 2.0.2
2014-07-17 00:28:31,697 dot2tex INFO dot2tex called with: ['/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/dot2tex', '--figonly', '-ftikz', '--debug', '-o', 'my_main-dot2tex-fig1.tex', 'my_main-dot2tex-fig1.dot']
2014-07-17 00:28:31,697 dot2tex INFO Program started in mypath/test
2014-07-17 00:28:31,697 dot2tex DEBUG Attempting to read data from my_main-dot2tex-fig1.dot
2014-07-17 00:28:31,698 dot2tex INFO Data read from my_main-dot2tex-fig1.dot
2014-07-17 00:28:31,698 dot2tex DEBUG Input data:
\input{0.dot}%

2014-07-17 00:28:31,699 dot2tex DEBUG Start conversion
2014-07-17 00:28:31,715 dot2tex ERROR Parse error:
\input{0.dot}%
^
Expected 'graph' (at char 0), (line:1, col:1)
2014-07-17 00:28:31,716 dot2tex ERROR Failed to parse graph
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/dot2tex/dot2tex.py", line 3001, in main
    s = conv.convert(dotdata)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/dot2tex/dot2tex.py", line 752, in convert
    main_graph = parse_dot_data(dotdata)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/dot2tex/dot2tex.py", line 233, in parse_dot_data
    graph = parser.parse_dot_data(dotdata)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/dot2tex/dotparsing.py", line 595, in parse_dot_data
    tokens = self.dotparser.parseString(ndata)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyparsing.py", line 1111, in parseString
    raise exc
ParseException: Expected 'graph' (at char 0), (line:1, col:1)
2014-07-17 00:28:31,719 dot2tex ERROR Failed to parse the input data. Is it a valid dot file?
Try to input xdot data directly. Example:
    dot -Txdot file.dot | dot2tex > file.tex

If this does not work, check that you have an updated version of PyParsing and
Graphviz. Users have reported problems with old versions. You can also run
dot2tex in debug mode using the --debug option:
    dot2tex --debug file.dot
A file dot2tex.log will be written to the current directory with detailed
information useful for debugging.
2014-07-17 00:28:31,719 dot2tex INFO ------- End of run -------

The important line above is:

2014-07-17 00:28:31,715 dot2tex ERROR Parse error:
\input{0.dot}%
^

The error trace is:

ERROR Failed to parse graph Traceback (most recent call last):

File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/dot2tex/dot2tex.py", line 3001, in main s = conv.convert(dotdata)

File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/dot2tex/dot2tex.py", line 752, in convert main_graph = parse_dot_data(dotdata)

File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/dot2tex/dot2tex.py", line 233, in parse_dot_data graph = parser.parse_dot_data(dotdata)

File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/dot2tex/dotparsing.py", line 595, in parse_dot_data tokens = self.dotparser.parseString(ndata)

File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyparsing.py", line 1111, in parseString raise exc ParseException: Expected 'graph' (at char 0), (line:1, col:1)

ERROR Failed to parse the input data. Is it a valid dot file? Try to input xdot data directly. Example: dot -Txdot file.dot | dot2tex > file.tex If this does not work, check that you have an updated version of PyParsing and Graphviz. Users have reported problems with old versions. You can also run dot2tex in debug mode using the --debug option: dot2tex --debug file.dot A file dot2tex.log will be written to the current directory with detailed information useful for debugging.

I am on Mac OS X v10.8.5 using dot2tex v2.9.0 installed with macports (dot2tex port @2.8.7_2).

dot2texi is v2008/05/07 v3.0p1, however the issue exists also in 83a6ddf9c0e0574f7c76f83a98c7d53a84313b8b.

@johnyf
Copy link
Contributor Author

johnyf commented Jul 17, 2014

This bug is caused by this regexp. Changing it for example to r"^\s*\\input\{(?P<filename>.+?)\}\%\s*$" reverses the bug (now \input{...}% is recognized correctly, whereas \input{...} not).

Considering that including a comment line is typical within packages, it may be desirable to change the regular expression used for this match.

@kjellmf kjellmf added this to the 2.9.1 milestone Jul 17, 2014
@kjellmf kjellmf self-assigned this Jul 17, 2014
@kjellmf
Copy link
Collaborator

kjellmf commented Jul 17, 2014

@johnyf I agree that it should be possible to include a comment. I will try to find a more robust regexp. Thanks for taking the time to locate the bug!

@johnyf
Copy link
Contributor Author

johnyf commented Jul 17, 2014

Thank you, after more attempts eventually I derived a command from the code of the dot2tex environment to directly call dot2tex and avoid using a fragile slide, details here.

kjellmf added a commit that referenced this issue Jul 24, 2014
kjellmf added a commit that referenced this issue Jul 24, 2014
@kjellmf kjellmf closed this as completed Jul 24, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants