Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't convert markdown to OneNote formatting #1538

Closed
andyylin opened this issue Aug 14, 2024 · 2 comments · Fixed by #1542
Closed

Can't convert markdown to OneNote formatting #1538

andyylin opened this issue Aug 14, 2024 · 2 comments · Fixed by #1542
Assignees
Labels
bug Something isn't working released Available in a released installer vector

Comments

@andyylin
Copy link

Problem to Solve

I tried converting a chunk of markdown to OneNote but got an error message:

To Reproduce

Steps to reproduce the behavior:

  1. Paste in markdown
  2. Select markdown container
  3. Press ALT + SHIFT + M
  4. See error

Expected Behavior

Markdown converts correctly.

Screenshots

If applicable, add screenshots to help explain your problem.

Environment (if applicable)

  • OneNote Version: Microsoft® OneNote® for Microsoft 365 MSO (Version 2407 Build 16.0.17830.20056) 64-bit
  • OneMore Version: 6.5.0

Additional Context

The page:
Setting_up_periodic_screenshots_with_Flameshot.zip

Log:

19|05:49:37.896| Running command ConvertMarkdownCommand
04|05:49:38.319| Error running command ConvertMarkdownCommand
04|05:49:38.319| System.TypeLoadException
Message: Could not load type 'System.Numerics.Vector' from assembly 'System.Numerics.Vectors, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Source: System.Memory
StackTrace:    at System.SpanHelpers.SequenceEqual(Byte& first, Byte& second, NUInt length)
   at Markdig.Helpers.TransformedStringCache.EntryGroup.TryGet(ReadOnlySpan`1 inputSpan)
   at Markdig.Helpers.TransformedStringCache.Get(ReadOnlySpan`1 inputSpan)
   at Markdig.Parsers.FencedBlockParserBase`1.DefaultInfoParser(BlockProcessor state, StringSlice& line, IFencedBlock fenced, Char openingCharacter)
   at Markdig.Parsers.FencedBlockParserBase`1.TryOpen(BlockProcessor processor)
   at Markdig.Parsers.BlockProcessor.TryOpenBlocks(BlockParser[] parsers)
   at Markdig.Parsers.BlockProcessor.TryOpenBlocks()
   at Markdig.Parsers.BlockProcessor.ProcessLine(StringSlice newLine)
   at Markdig.Parsers.MarkdownParser.ProcessBlocks(BlockProcessor blockProcessor, String text)
   at Markdig.Parsers.MarkdownParser.Parse(String text, MarkdownPipeline pipeline, MarkdownParserContext context)
   at River.OneMoreAddIn.Commands.OneMoreDig.ConvertMarkdownToHtml(String path, String markdown)
   at River.OneMoreAddIn.Commands.ConvertMarkdownCommand.<Execute>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at River.OneMoreAddIn.CommandFactory.<Run>d__6.MoveNext()
TargetSite: [System.Memory] System.SpanHelpers::SequenceEqual()
@andyylin andyylin added bug Something isn't working unread I have seen it or had time to refine it yet labels Aug 14, 2024
@stevencohn stevencohn removed the unread I have seen it or had time to refine it yet label Aug 14, 2024
@stevencohn stevencohn added the next-release Addressed but not yet released label Aug 15, 2024
@stevencohn stevencohn self-assigned this Aug 15, 2024
@stevencohn stevencohn added released Available in a released installer and removed next-release Addressed but not yet released labels Aug 25, 2024
@andyylin
Copy link
Author

andyylin commented Sep 6, 2024

This block of Markdown still fails to convert properly. The command executes, but not all of it is converted properly:

image

Here's a comprehensive summary of our conversation, including the setup for crontab and crontab-ui, along with the final script for taking and processing screenshots.


Chat Summary

Objective: To create a script that takes a screenshot, resizes it, and converts it to HEIC format, while also setting up a cron job using crontab and crontab-ui for automation.

1. Screenshot Script Development

  • Initial Requirements: Create a script to take a screenshot using Flameshot, resize it, and convert it to HEIC format.
  • Final Script: Below is the complete take_screenshot.sh script:
#!/bin/bash

# Set the JPEG quality (0-100)
jpeg_quality=80

# Set the desired maximum image dimension
max_dimension=2048  # Changphe this value as needed

# Get the current date components
year=$(date +%Y)
month=$(date +%m)
day=$(date +%d)

# Create the directory structure with spaces
screenshot_dir="$HOME/Pictures/My Screenshots/$year/$month/$day"
mkdir -p "$screenshot_dir"

# Define the PNG and HEIC file paths
png_file="$screenshot_dir/screenshot_$(date +%Y%m%d_%H%M%S).png"
heic_file="${png_file%.png}.heic"

# Take a screenshot and save it as PNG
flameshot full --path "$png_file"

# Check if the PNG file exists before conversion
if [ ! -f "$png_file" ]; then
    echo "PNG file does not exist: $png_file"
    exit 1
fi

# Resize the PNG file to the maximum dimension and convert it to HEIC with specified quality
if ! sips -s format heic -s formatOptions "$jpeg_quality" -Z "$max_dimension" "$png_file" --out "$heic_file"; then
    echo "Error converting PNG to HEIC: $png_file"
    exit 1
fi

# Optionally, remove the original PNG file
rm "$png_file"

Key Features of the Script:

  • Quality Control: The quality of the HEIC output can be adjusted by changing the jpeg_quality variable.
  • Resizing: The script resizes the image to a maximum dimension specified by the max_dimension variable while maintaining the aspect ratio.
  • Directory Structure: Screenshots are organized into a folder structure based on the current date.

2. Setting Up Cron Jobs

  • Using Crontab: To schedule the script to run at specific intervals, you can use the crontab command:
    • Open your crontab for editing:
      crontab -e
    • Add a line to schedule the script. For example, to run the script every hour:
      0 * * * * /bin/bash ~/take_screenshot.sh

3. Using Crontab-UI

  • What is Crontab-UI: Crontab-UI is a web-based GUI for managing cron jobs, making it easier to add, edit, and delete scheduled tasks.

  • Installation Steps:

    1. Install Node.js: Ensure you have Node.js installed on your system.
    2. Install Crontab-UI:
      npm install -g crontab-ui
    3. Start Crontab-UI:
      crontab-ui
      This will start the service and make it available at http://localhost:8000.
  • Using Crontab-UI:

    • Open your web browser and navigate to http://localhost:8000.
    • Click “Get from Crontab” to load existing jobs.
    • Add new jobs by specifying the command and schedule, and then save your changes.

Conclusion

This summary encapsulates the entire process of creating a screenshot script, setting up cron jobs, and using Crontab-UI for easier management. You can copy and paste this summary into OneNote for your future reference. If you have any further questions or need additional modifications, feel free to ask!

Citations:
[1] https://www.techrepublic.com/article/how-to-install-crontab-ui-for-remote-use/
[2] https://ubuntuforums.org/archive/index.php/t-185993.html
[3] https://askubuntu.com/questions/2368/how-do-i-set-up-a-cron-job/2369
[4] https://opensource.com/article/22/5/cron-crontab-ui
[5] https://www.cyberciti.biz/faq/how-do-i-add-jobs-to-cron-under-linux-or-unix-oses/

@stevencohn stevencohn reopened this Sep 6, 2024
@stevencohn stevencohn added the markdown Related to markdown label Sep 23, 2024
@stevencohn stevencohn added next-release Addressed but not yet released and removed released Available in a released installer labels Oct 13, 2024
@stevencohn
Copy link
Owner

Resolved by #1583

@stevencohn stevencohn added vector and removed markdown Related to markdown labels Oct 20, 2024
@stevencohn stevencohn added released Available in a released installer and removed next-release Addressed but not yet released labels Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released Available in a released installer vector
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants