#!/usr/bin/python########################################################## Author: Alex Hogen# Created: April 14, 2016# Last updated: April 14, 2016## This code is not fully functinal. It is only the start # of an idea I have, but I don't have time to finish it # right now.## Ideally, this script will be able to convert LaTeX# sections to Creole headings, convert basic tables and# bulleted/itemized lists. Nothing too fancy. Just a way# to use existing LaTeX documentation in WIKIs instead of# trying to convert everything yourself...######################################################### Used to extract file name from file pathimportntpathlatex_file_path=input("Enter the path to the input LaTeX file: ")# Check to make sure file has the expected extentioniflatex_file_path.endswith('.TEX')orlatex_file_path.endswith('.tex'):print("Beginning to convert ",latex_file_path,"\n")# Open the LaTeX filef_latex=open(latex_file_path,"r")# Open/create new Creole file in same directory as source filef_creole_name=ntpath.basename(latex_file_path);f_creole_path=latex_file_path.replace(f_creole_name,"");f_creole_name=f_creole_name.replace(".tex",".wiki");f_creole_path=f_creole_path+f_creole_name;f_creole=open(f_creole_path,"w");# Priming readlatex_line=f_latex.readline();whilelatex_line.find("\begin{document}")==-1:print("Searching for beginning of document body...");latex_line=f_latex.readline();print("Beginning of document body found at line ",f_latex.tell());# Close the LaTeX file and the new Creole Wiki filef_latex.close();f_creole.close();# Print error message if file extention is incorrectelse:print("\nERROR: Expecting a file ending with .tex extention.\n")print("Exiting...")
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.