Giter VIP home page Giter VIP logo

dokuwiki2wikijs's People

Contributors

liaungyip avatar thoni56 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

dokuwiki2wikijs's Issues

pandoc: Unknown reader: dokuwiki

running on ubuntu against a backup of my dokuwiki I get the error :

pandoc: Unknown reader: dokuwiki Traceback (most recent call last): File "dokuwiki2wikijs.py", line 279, in <module> lines = convert_file(path, path) File "dokuwiki2wikijs.py", line 214, in convert_file metadata = get_metadata(lines, title) File "dokuwiki2wikijs.py", line 34, in get_metadata "title": "\""+first_heading_or_filename(lines, pagename)+"\"" File "dokuwiki2wikijs.py", line 22, in first_heading_or_filename if lines[0][0] == '#': IndexError: string index out of range

Same error as #1

I get the same error as in #1 reported but with pandoc version 2.2.1-3+b2

didnt convert dokuwiki internal URLs

Thanks for the effort on this script.

i donno if I did it wrong or not, but i just followed the basic instructions. What I got was all my txt files as .md files but the URLs for internal pages didnt convert right.

Example:

[[New Purchase List]]

converted to:

[New Purchase List](New Purchase List)

but it should have been

[New Purchase List](/new_purchase_list)

Once I had the output in my filestorage folder I wrote this script to clean up the above issue and then the import worked mostly well.
Figured I'd post this in case someone else has the same issue.

#!/usr/bin/env python3

### Imports
import os, sys, re, fileinput


### FUNCTIONS
def getFiles(folder_root):
	for root, dirs, files in os.walk((folder_root)):
		# get all files in specified folder
		for file in files:
			# get full path to file
			file_full = ( os.path.join(root, file) )
			# check only specific files
			if not file.endswith(".md"):
				continue
			else:
				file_list.append(file_full)
                
def regexSearch(regex, string) -> bool:
	if re.search((regex), (string), re.IGNORECASE):
		return(True)
	else:
		return(False)				

def parseFile(file_full):
    for line in fileinput.input(file_full, inplace=True):
        line2 = line
        regex = '^(.+\]\()(.+\s.+)$'
        if regexSearch(regex, line2):
            result = re.search(regex, line2, re.IGNORECASE)               
            line2 = line2.replace(line2, result.group(1) + result.group(2).replace(' ','_'))
        regex = '^(.+\]\((?!\/))(.+.+)$'                    
        if regexSearch(regex, line2):
            result = re.search(regex, line2, re.IGNORECASE)
            line2 = line2.replace(line2, result.group(1)+"/"+result.group(2).lower())
        line = line2
        print(line)
     # sys.stdout.write(line) # use this if you want no line breaks

### RUNTIME
file_list = []
getFiles('./') # this should be the root folder where the md files are
for f in file_list:
	print(f)
	parseFile(f)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.