Asciidoctor: how to replace expression in included document? - asciidoctor

Given asciidoctor file my-document.adoc with the content:
include::included-document.adoc[]
included-document.adoc contains
The content of this file cannot be changed.
This text *has to be replaced*.
When I render my-document.adoc, I want to have the visible content
The content of this file cannot be changed.
This text has successfully been replaced.
Is this possible without changing included-document.adoc? my-document.adoc may be changed.

There is an Asciidoctor extension lab that provides examples for this, for example an include processor that exchanges tabs for spaces.
I hope this gets you started.
https://github.com/asciidoctor/asciidoctor-extensions-lab/blob/master/lib/whitespace-include-processor.rb

Related

Add Bookmarks to pdf using Pymupdf

How to add Bookmarks to pdf using Pymupdf. I have seen many ways using PyPDF2 but since I'm already using pymupdf for other annotations I would prefer pymupdf for adding bookmarks. Also would like to highlight the text and add bookmarks to it.
You cannot add single bookmarks like you can in other packages.
If you have looked at the details there - or rather in the respective PDF specification, this is an overly / unnecessarily complex task.
PyMuPDF in contrast has this simple approach to offer:
Prepare a Python list that looks like a traditional table of contents (TOC):
Every line in the list contains the hierarchy level, the text to display and the page number. Optionally also some information where on the target page the pointer goes to.
Then use doc.set_toc(toc_list). All pesky detail is taken care of for you.
If the PDF already has a TOC, extract it to a list of that same structure via toc_list = doc.get_toc().
Then modify as required.

Editing xmp tags pyexiv2 modify_xmp does not replace xmp tags correctly

I am trying to write a script that will loop through a large number of images and write new xmp tags based on certain criteria.
I am using pyexiv2 to read and modify the 'Xmp.dc.subject' tag.
I am able to assign a new set of tags to the image, and using pyexiv2.read_xmp() to check my results shows that the new set of tags has replaced the old set of tags, as expected.
However, when I check the properties in windows explorer or another photo manager, the old tags remain in addition to the new set of tags.
see my code below
from pyexiv2 import Image
path=some_path
img=Image(path)
tags=img.read_xmp()
tags.get('Xmp.dc.subject') ####outputs list of tags ['old_tag1', 'old_tag2', 'old_tag3']
newtags=['new_tag1','new_tag2']
dict1={'Xmp.dc.subject':newtags}
img.modify_xmp(dict1)
img.close()
Now, when I open properties of the file in Explorer, or check in a photo manager software, the tags on the file are ['old_tag1', 'old_tag2', 'old_tag3','new_tag1','new_tag2']. The expected behaviour as stated in the pyexiv2 tutorial is that the new list of tags will replace the old tags.
I have tried using py3exiv2, but I am having problems with that library due to an error referencing Microsoft Visual Studio.
Is there a way to achieve my outcome ideally using pyexiv2, or alternatively using any other method?
I found the solution to this problem.
Windows explorer (and Adbobe Bridge, and i'm guessing other software too) displays both xmp tags and iptc tags.
So if you modify the xmp tags only, explorer (or other software) will show the new xmp tags as well as the old iptc tags.
So the solution is to use modify_xmp() and modify_iptc() to change both sets of tags.

List of all BibTex entries in a .bib file, to generate Hakyll publication list?

I'm making a personal website with Hakyll, and I'd like to list my publications.
I've found this module and this guide for how to print the references from a markdown document at the bottom.
The problem with this is, it assumes you've got some document, where you cite all the things you want printed.
What I want is to generate a document that lists every document my .bib file. In particular:
I don't want to have to manually write the bibtex name of each publication I want listed
I just want the "references" section printed, i.e. there's no place in the document where the publication is referenced, they're just listed at the end.
Is it possible to get this information from the Hakyll.Web.Pandoc.Biblio module? Or do I need to separately parse the .bib file to get this? And once I do, how would I make go about generating this page with Hakyll?
You could use this trick from the pandoc's manual, the equivalent of biblatex's \nocite{*}:
It is possible to create a bibliography with all the citations,
whether or not they appear in the document, by using a wildcard:
---
nocite: |
#*
---

How to apply Dreamweaver templates on an existing site

I have an existing site in a path, and I've pointed the DreamWeaver site to it.
Under \templates there is a master.dwt file. But whenever I save this file, none of the html files which should make use of it change. What do I need to do to get DW to update the html files that make use of it? And how does DW know which files should be updated based on the template changing? Does it use an internal store or something because every time I copy the site to another machine, I'll need to link up all the pages to the relevant templates again.
I've tried going into Modify | Templates | Apply, but no templates are listed. I have a .dwt file in the path so why isn't it picking it up??
There's several possible issues in play here:
For Dreamweaver to properly recognize the existence of the template, the folder in the root of the site should be Templates and not templates.
Once Dreamweaver "sees" the Template properly you then need to make sure that the proper code is present in the child HTML files so Dreamweaver knows which files to update via the template. This code takes the form of HTML comments scattered throughout the page. You will always have the following line after the <html> tag:
<!-- InstanceBegin template="/Templates/TemplateName.dwt" codeOutsideHTMLIsLocked="false" -->
After that, editable regions are delineated with code that will look like this:
<!-- InstanceBeginEditable name="someregion" -->
stuff you can edit
<!-- InstanceEndEditable -->
Without the above, the child pages will not respond to the template.
Now for the real bad news. Unless the existing pages match up with the template exactly, you are going to have all kinds of problems getting the template to play nicely with the existing content. Doing Modify | Template | Apply Template to the page when the page is already fully formed will generate a dialog box that asks you map the content to the editable regions in the template. But if the rest of the design elements vary from what the template contains, Dreamweaver will preserve those tags alongside what the template will introduce which usually creates a ton of duplicated tags and broken layouts.
You would be FAR better off creating new, blank pages from the Dreamweaver Template and copy/pasting the contents into the editable area and then overwriting the "old" pages with the Save As command.
I just encountered this issue myself. I realize this original question was posted some time ago, but for anyone who might encounter this problem in the future, I am posting my solution.
If the only changes made to the template relate to one or more elements contained in an attached/linked file (such as a CSS style sheet or JS file), which changes Dreamweaver allows directly from the .dwt template itself, using the style boxes at the side/bottom, then Dreamweaver does not perceive any change to the actual .dwt file itself. If you want those changes to "take effect" and apply them to all pages, you might type a change to the .dwt file itself, click "save all" - undo the change and click "save all" again. This step is really not entirely necessary, as the changes to dependent files can be affected to the website by putting the dependent file to the website.
Also, Dreamweaver will apply changes to CSS/JS dependent files, across the board, but may continue to use a cache, until closed and reopened.

SharePoint randomly replacing file names in web parts?

Ok SharePoint is driving me crazy and I need to see if anyone has encountered a similar problem or knows of a solution:
I have a content editor webpart with some HTML including links to PDF files that I've modified slightly to append an employee number querystring ie:
<a href="http://moss.company.com/group/home/EPermits
/Blank%20Form%20Templates/_blank_breach_permit.pdf?empNum=">New Breach Permit</a>
And SharePoint seems to randomly replace the filename with aab04168 or some other similar characters:
<a href="http://moss.company.com/group/home/EPermits
/Blank%20Form%20Templates/aab04168?empNum=">New Breach Permit</a>
After this happened a few times with no explanation I tried changing the content editor webpart to look directly at a documentLinks.html file located in the Shared Documents folder of the SharePoint site and guess what... SharePoint edited that document and replaced my filenames with random characters in there too!
Figuring that filenames beginning with an underscore could be triggering some internal SharePoint procedures I've renamed all the files to remove the starting underscore--unfortunately the problem isn't immediately reproducible and I'm waiting right now to see if I run into any more trouble.
edit: the underscore in the filename didn't help... my documentLinks.html wound up getting modified and all the hrefs were replaced with random characters again. Now I'm setting the hrefs in javascript with the filename text concatenated together from multiple strings.
linkEle.href = ".../EPermits/Blank%20Form%20Templates/blank" + "_Chemical_Usage.pdf?empNum=" + empNumber;
Sharepoint uses the 'Title' field of the Document Library as the file's name. If the PDF file name is not stored in the Title field then Sharepoint might be creating a unique 'Title' for you. Check the column structure of your Document Library and ensure that you are storing the PDF filename in the 'Title' field.

Resources