SlicerLatinAmerica / TutorialMaker

1 stars 5 forks source link

Store screenshot annotations in tutorial's markdown file #12

Open lassoan opened 8 months ago

lassoan commented 8 months ago

The annotation editor should read the list of annotated screenshots from the tutorial text (markdown file).

For example, the SlicerFourMinuteTutorial.md file can contain screenshots like this: https://github.com/SlicerLatinAmerica/TestSlicerTutorials/blob/8d702775d8db9c30e52c91bfc8576505ea81bc01/Tutorials/FourMinuteTutorial/FourMinuteTutorial.md?plain=1#L46-L54

If the editor finds an image caption starting with Screenshot: then the annotation editor should add that image to its image list. The annotation editor should also read the list of annotations from the caption and apply it to the screenshot. For example, this image is in the markdown file:

![Screenshot:({"annotation":"click","widget":"toolbar/layouts","label":"1"},{"annotation":"click","widget":"toolbar/layouts/conventional","label":"2"})](Screenshots/en-US/002-part1-after-scene-load.png)

Then the image caption can be parsed with this very simple code:

imageCaption = 'Screenshot:({"annotation":"click","widget":"toolbar/layouts","label":"1"},{"annotation":"click","widget":"toolbar/layouts/conventional","label":"2"})'

screenshotPrefix = "Screenshot:"
if imageCaption.startswith(screenshotPrefix):
    annotations = eval(imageCaption.removeprefix(screenshotPrefix))

annotation now contains the list of annotations and its arguments:

annotation = (
    {'annotation': 'click', 'widget': 'toolbar/layouts', 'label': '1'},
    {'annotation': 'click', 'widget': 'toolbar/layouts/conventional', 'label': '2'}
)

After the annotation is edited in the annotation editor, the editor should write the modified annotations back into the markdown file.

LuskasHusty commented 7 months ago

@enriquehdez98 The PDF/HTML Creator has to work with the markdown file.