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

Add Quarto support #200

Merged
merged 17 commits into from
Apr 14, 2024
Merged

Conversation

svilupp
Copy link
Contributor

@svilupp svilupp commented Aug 7, 2022

Closes #199

Changes:

  • parse properly Quarto arguments #| echo:false
  • provide Quarto-specific codefence (refactored to a separate function)
  • save files with extension .qmd
  • all functionality tested
  • updated documentation with the new flavor

All tests are passing
Code formatted with JuliaFormatter (default setting as no specific preference was indicated)

- parse properly Quarto arguments `#| echo:false`
- provide Quarto codefence (refactored to separate function)
- save files with extension `.qmd`
- all functionality tested
- updated documentation
@fredrikekre
Copy link
Owner

Thanks for the PR. Can you drop all the formatting changes? Very difficult to review otherwise.

This reverts commit fa050c7.
@svilupp
Copy link
Contributor Author

svilupp commented Aug 8, 2022

Thanks for the PR. Can you drop all the formatting changes? Very difficult to review otherwise.

Yes, of course. I've reverted it. I can open a separate PR with JuliaFormatter later.

@svilupp
Copy link
Contributor Author

svilupp commented Aug 23, 2022

Hi @fredrikekre, would you have any thoughts on the PR?

@fredrikekre
Copy link
Owner

I'm om vacation but will have a look in a week or two.

@svilupp
Copy link
Contributor Author

svilupp commented Nov 9, 2022

Hi @fredrikekre, I was wondering if you have any thoughts on the PR?

My team and I have been using it for several months now, so it seems to work pretty well.

@svilupp
Copy link
Contributor Author

svilupp commented Apr 19, 2023

Hi @fredrikekre, I was wondering if there is anything I can do to get this merged.

I've updated to the latest and re-ran tests. All pass, including the additions for the functionality added.

Are there any suggestions or concerns that you have about this tweak?

@lbenet
Copy link

lbenet commented May 10, 2023

Is there an easy way to test your proposal (using my own .qmd files)?

@svilupp
Copy link
Contributor Author

svilupp commented May 10, 2023

Is there an easy way to test your proposal (using my own .qmd files)?

Yeah, very simple. Just add my branch of Literate, eg, in your environment:
]add https://github.com/svilupp/Literate.jl.git#add-quarto-support

and then simply using Literate; Literate.markdown("filename.jl",flavor=Literate.QuartoFlavor())

My workflow is to have it in the global environment and call it with VSCode tasks. Ie, I simply click on "JL to HTML" when I have my script opened and separate process is spun to produce my Quarto report (while I can keep working in my project)

Example tasks.json (in VSCode)

    "version": "2.0.0",
    "tasks": [
        {
            "label": "JL to HTML",
            "type": "shell",
            "command": "echo Finished conversion to HTML",
            "dependsOrder": "sequence",
            "dependsOn": ["JL to QMD", "QMD: HTML Render"]
        },
        {
            "label": "JL to QMD",
            "type": "shell",
            "command": "julia --startup-file=no -e 'using Literate; Literate.markdown(\"${file}\",\"${fileDirname}\",flavor = Literate.QuartoFlavor(),credit=false)'"

        },
                {
            "label": "QMD: HTML Render",
            "type": "shell",
            "command": "quarto render ${fileDirname}${pathSeparator}${fileBasenameNoExtension}.qmd --to html",
            "problemMatcher": []
        }]

FYI. I think I'll create a fork/package extension to be able to register it and add it like a normal package.

src/Literate.jl Outdated Show resolved Hide resolved
src/Literate.jl Outdated Show resolved Hide resolved
@svilupp
Copy link
Contributor Author

svilupp commented May 12, 2023

Docs checked. Output formats page renders correctly.

The question is where we should add also a full example to show the application / make it easier to start

@fredrikekre
Copy link
Owner

Thanks, will have a look.

The question is where we should add also a full example to show the application / make it easier to start

I have been thinking for some time to have a section where I link to real life usage of Literate as inspiration for setups etc. If you have something public let me know and I will get around to write up something.

@svilupp
Copy link
Contributor Author

svilupp commented May 16, 2023

I have been thinking for some time to have a section where I link to real life usage of Literate as inspiration for setups etc. If you have something public let me know and I will get around to write up something.

Sorry, I forgot to reply. No, I don't have anything public, but I could easily sanitize a few examples to show the different quarto features (to be hosted in Literate.jl)

@svilupp
Copy link
Contributor Author

svilupp commented May 29, 2023

I've looked into the Docs failure. It doesn't seem to be related.

I've refreshed Manifest.toml and local build works without a problem.

Looking at the failure, it's coming from StatsBase and Plots. I suspect it's due to JuliaStats/StatsBase.jl#840 and its removal of type aliases ("ERROR: LoadError: UndefVarError: Float not defined".

I'm unsure how to force Github Actions to load more up-to-date deps (I can build locally with StatsBase 0.34 vs StatsBase 0.33.21 in the CI)

@fredrikekre
Copy link
Owner

I've refreshed Manifest.toml and local build works without a problem.

You have to commit the changes then too.

I will review and merge this week, I should have some time. Sorry again for slow responses

@svilupp
Copy link
Contributor Author

svilupp commented May 30, 2023

You have to commit the changes then too.

Sorry, I didn't make myself clear.
I couldn't replicate the error locally, I merely deleted and re-instantiated my Manifest.toml to check if its some breaking release (no changes to Project.toml, so nothing to commit)

To replicate the error, I'd have to explicitly ]add [email protected], which breaks. I'm hesitant to add a compat bound, because it's a 2nd-order dependency (docs -> Plots.jl -> StatsBase.jl -> SortingAlgorithms).

We could force Plots to something higher (1.38), but I'm not sure when the issue was introduced, so we could be overly
restrictive.

Would you prefer to be safe and set compat to [email protected]?

@fredrikekre
Copy link
Owner

I couldn't replicate the error locally, I merely deleted and re-instantiated my Manifest.toml to check if its some breaking release (no changes to Project.toml, so nothing to commit)

The manifest is commited.

@svilupp
Copy link
Contributor Author

svilupp commented May 30, 2023

The manifest is commited.

Oh, I didn't clock that -- that explains the issues.
I've committed my Manifest (I run on an arm-based Mac machine, but hopefully nothing in there is platform specific)

docs/src/outputformats.md Outdated Show resolved Hide resolved
@svilupp
Copy link
Contributor Author

svilupp commented Jul 28, 2023

@fredrikekre, are you perhaps at JuliaCon? We could meet up and discuss the next steps?

@fredrikekre
Copy link
Owner

I wasn't. I think we can merge this. Perhaps in a version 3.0 it make sense to split up the flavors into Literate.quarto etc instead of trying to push it all into Literate.markdown.

@svilupp
Copy link
Contributor Author

svilupp commented Aug 13, 2023

Hi @fredrikekre, would you mind merging this PR?

We're considering giving a presentation on benefits of Literate.jl + Quarto, but it would be odd to ask people to install from a fork...
I'm happy to review the structure for 3.0.

Updates:

  • updated to latest main
  • tests pass (tested on 1.10 and 1.9)
  • docs build

If people open issues related to the quarto functionality, just tag me. I have a lot of experience debugging it :)

Thank you!

@svilupp
Copy link
Contributor Author

svilupp commented Aug 21, 2023

Happy Monday, @fredrikekre!

Is there something that I can do to get this merged?

Thank you

src/Literate.jl Outdated
@@ -75,8 +76,9 @@ function parse(content; allow_continued = true)
if !(chunks[end] isa CodeChunk)
push!(chunks, CodeChunk())
end
# remove "## " and "##\n"
line = replace(replace(line, r"^(\h*)#(# .*)$" => s"\1\2"), r"^(\h*#)#$" => s"\1")
# remove "## " and "##\n", strip the leading "#" from "## xyz" and "##| xyz"
Copy link
Owner

@fredrikekre fredrikekre Aug 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use #| directly in the source code and make no transformation? Alternatively, I think this transformation should only be done for quarto output.

@svilupp
Copy link
Contributor Author

svilupp commented Nov 23, 2023

Hi @fredrikekre ,

Hope all is well! Is there any chance we could reach a conclusion on the PR?

I've responded in August to your comments but haven't heard back.
The current version isn't perfect but it works well for everyone (we have a bunch of people using it) and is simple to pick up as it follows an easy mental model -- could we consider merging this or rejecting this?

I'm happy to fork into LiterateQuarto.jl, because this is the only useful functionality of Literate for us.
However, I'm conscious that forks duplicate work, so I was hoping to prevent it.

Would you prefer we abandon this PR and create a separate package?

Thank you in advance for your response.

@fredrikekre
Copy link
Owner

I was waiting for #200 (comment)

@svilupp
Copy link
Contributor Author

svilupp commented Nov 23, 2023

I was waiting for #200 (comment)

Thank you, I havent realized that my explanation wasn’t sufficient. I’ll follow your suggestion and update it within the next few days.

@fredrikekre fredrikekre changed the title Add quarto support Add Quarto support Apr 14, 2024
@fredrikekre fredrikekre merged commit 8abaeeb into fredrikekre:master Apr 14, 2024
8 checks passed
Copy link
Owner

@fredrikekre fredrikekre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, sorry it took a while to get this in.

CHANGELOG.md Show resolved Hide resolved
```
# ---
# title: "My Report"
# jupyter: julia-1.9
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this and the installation notes below be updated?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FR: Output to Quarto markdown flavour
4 participants