Skip to content

feat: print the note as text when stdout is not a terminal - #185

Open
ryanlewis wants to merge 1 commit into
mainfrom
feat/print-mode
Open

ryanlewis wants to merge 1 commit into
mainfrom
feat/print-mode

Conversation

@ryanlewis

Copy link
Copy Markdown
Owner

When smd's output is piped or redirected, it now lays the note out once and prints it as text instead of opening the browser:

pbpaste | smd | pbcopy
smd --color always README.md | less -R
  • The width is $COLUMNS, else the terminal's, else 80, held to max_width.
  • Diagrams, maths and images print as their markdown source.
  • New --color auto|always|never flag. Text is plain unless --color always, which keeps colours and styles as SGR escapes for less -R.
  • A reader that stops early, as head does, is not an error.
  • README's Usage section documents it.

Tests cover the colour choice, width rules, SGR codes, plain output with no trailing blanks, bold in colour, and wrapping at the width.

When smd's output is piped or redirected, it now lays the note out once
and prints it as text instead of opening the browser, so
`pbpaste | smd | pbcopy` and `smd note.md | less -R` work.

- The width is $COLUMNS, else the terminal's, else 80, held to max_width.
- Diagrams, maths and images print as their markdown source.
- --color auto|always|never: text is plain unless --color always, which
  keeps colours and styles as SGR escapes for `less -R`.
- A reader that stops early, as head does, is not an error.

This branch has not been deployed

No deployments
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.

1 participant