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 lines to the highlighted code blocks? #121

Closed
1 of 2 tasks
Tracked by #147 ...
badlydrawnrob opened this issue Jan 21, 2024 · 1 comment
Closed
1 of 2 tasks
Tracked by #147 ...

Add lines to the highlighted code blocks? #121

badlydrawnrob opened this issue Jan 21, 2024 · 1 comment

Comments

@badlydrawnrob
Copy link
Owner

badlydrawnrob commented Jan 21, 2024

Pandoc gives the option to add lines to fenced code blocks
Anki doesn't recognise some of the features1

  • Very useful for websites
  • Only moderately useful for Anki

Example of syntax for numbered lines

This example has way too much code
Ideally, you should have as little code as possible to get the point across
☝️One idea per card!

``` {.elm .numberLines}
..

-- View --
view model =
  ..
    ..
    , div [ id "thumbnails" ]
        (List.map
          (viewThumbnail model.selectedUrl)  -- Apply the function
          model.photos
        )
    ..

-- Helper functions --
urlPrefix =
  "http://elm-in-action.com/"

viewThumbnail selectedUrl thumb =
  img [ src (urlPrefix ++ thumb.url)
      , classList [ ("selected", selectedUrl == thumb.url) ]
      ..
      ] []

-- Model --
{ photos =
    [ { url = "1.jpeg" }  -- Our list of urls
    , { url = "2.jpeg" }
    , { url = "3.jpeg" }
    ]
  , selectedUrl = "1.jpeg"  -- Has the url been selected?
  }

Footnotes

  1. Surprise, surprise, we can't navigate to ids in Anki's desktop browser. So the only usefulness of adding lines to the code is to indicate which line we're talking about.

@badlydrawnrob
Copy link
Owner Author

For now, I think this is an optional extra and can be added to a Child Theme if required. It could be somewhat useful to reference a number to a piece of code, but I think a better way is to strip the code back to it's absolute minimal that references the question we're asking. You could always link to a Github commit, or repo file and link to the line number like this.

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

No branches or pull requests

1 participant