In case its useful to anyone, below is some regular expressions to turn (at 
least some) of the local-relative links to tiddly pretty links:

import re


regex = r"<a.+?href=\"(?!https?)([^\"]+?)(?:\.html)?\"[^>]*>([^<]+)<\/a>"


test_str = "I want to turn <a href=\"local-link.html\">title</a> to a 
particular wiki format: [[title|local-link]]"


subst = "[[$2|$1]]"


# You can manually specify the number of replacements by changing the 4th 
argument
result = re.sub(regex, subst, test_str, 0)


if result:
    print (result)


See explanation here: https://regex101.com/r/vkN20z/3


On Friday, October 13, 2017 at 12:32:46 PM UTC-5, Diego Mesa wrote:
>
> Hello,
>
> I frequently check Cosma Shalizi's "Notebooks": 
>
> http://bactra.org/notebooks
>
> I find myself copying links from them, and copying/pasting etc. I thought 
> it would be excellent for me to "import" each notebook into its own tiddler 
> in my wiki, but I have no idea how to accomplish this. For one, Im using 
> the single file version, which I like. Second, I'd have to change all of 
> the <mathjax> calls to "$$". Third, I'd have to change all links like "
> bactra.org/noteboks/***" to be [[***]]", but keep all other bactra and 
> non-bactra links intact. Fourth, I'd have to develop this script in such a 
> way as to be able to be periodically run and import new changes to 
> notebooks, while preserving the changes I've made to the tiddlers in the 
> meantime. 
>
> This seems like quite a task. Does anyone know of anything similar done in 
> the past that I can use as a starting off point?
>
> Thank you,
> Diego
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/9d47ee27-8eec-4a72-8590-e78d380e5e9e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to