aboutsummaryrefslogblamecommitdiffstats
path: root/site-src/plugins/orgmode/__pycache__/orgmode.cpython-36.pyc
blob: 0b7389bbae3646e2c6a5d58ba108d45ccfb39536 (plain) (tree)





















































                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
3

@��ZL�@s�dZddlmZddlZddlZddlmZmZmZddl	Z	yddl
mZWnek
rde
ZYnXddlmZddlmZmZyddlmZWnek
r�dZYnXGd	d
�d
e�ZdS)zz Implementation of compile_html based on Emacs Org-mode.

You will need to install emacs and org-mode (v8.x or greater).

�)�unicode_literalsN)�abspath�dirname�join)�OrderedDict)�PageCompiler)�req_missing�makedirs)�write_metadatac@s0eZdZdZdZddd�Zddd�Zd	d
�ZdS)
�CompileOrgmodez0 Compile org-mode markup into HTML using emacs. �orgmodeTNc
Cszttjj|��y�dddtttt��d�ddjt|�t|��g}tjdkr^|dj	d	d
�|d<t
j|�tj
|ddd
��}|jj|j�dd�\}}	WdQRXtj
|ddd
��}
|
j|�WdQRX|dkr�|	r�|jjd|�n|j||	7<Wn�tk
�r>}z.ddl}|j|jk�r.tddgddd�WYdd}~Xn8t
jk
�rt}ztdj||j���WYdd}~XnXdS)z3Compile the source file into HTML and save as dest.�emacsz--batchz-lzinit.elz--evalz (nikola-html-export "{0}" "{1}")�nt��\z\\�rzutf-8)�encodingT)�with_dependenciesN�wz4Cannot save dependencies for post {0} (post unknown)rzorg-modezuse the orgmode compilerF)�pythonzBCannot compile {0} -- bad org-mode configuration (return code {1}))r	�os�pathrrr�__file__�format�name�replace�
subprocess�
check_call�io�open�site�apply_shortcodes�read�write�logger�error�_depfile�OSError�errno�ENOENTr�CalledProcessError�	Exception�
returncode)
�self�source�dest�is_two_file�post�lang�command�inf�output�shortcode_deps�outf�er(�r9�:/home/gramanas/code/ck/site-src/plugins/orgmode/orgmode.py�compile;s6

"zCompileOrgmode.compilecCs:y|jj|}Wntk
r(d}YnXt||||d�S)z,Compile the post into HTML (deprecated API).N)r �post_per_input_file�KeyErrorr;)r-r.r/r0r1r9r9r:�compile_html`s

zCompileOrgmode.compile_htmlc	Ks�|jdd�}|jdd�}|jdd�t�}|j|j�|j|�ttjj|��tj	|ddd��~}|r�|j
d�tr�|j
t|��n(x&|j�D]\}}|j
d	j
||��q�W|j
d
�|j
d�|r�|j
|�n
|j
d�WdQRXdS)
N�content�onefileF�is_pagezw+zutf-8)rz#+BEGIN_COMMENT
z.. {0}: {1}
z#+END_COMMENT
z

zWrite your post here.)�popr�update�default_metadatar	rrrrrr#r
�itemsr)	r-r�kwr?r@�metadata�fd�k�vr9r9r:�create_postis&



zCompileOrgmode.create_post)TNN)T)�__name__�
__module__�__qualname__�__doc__rr;r>rKr9r9r9r:r6s

%
	r)rO�
__future__rrr�os.pathrrrr�collectionsr�ImportError�dict�nikola.plugin_categoriesr�nikola.utilsrr	r
rr9r9r9r:�<module>s