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

feat: syntax highlighting using chroma #1

Merged
merged 3 commits into from
Oct 5, 2021
Merged

Conversation

elianiva
Copy link
Member

@elianiva elianiva commented Oct 5, 2021

image

@elianiva elianiva requested a review from aldy505 October 5, 2021 02:19
platform/highlight/highlight.go Outdated Show resolved Hide resolved
platform/highlight/highlight.go Outdated Show resolved Hide resolved
handlers/get.go Outdated Show resolved Hide resolved
Copy link
Member

@aldy505 aldy505 left a comment

Choose a reason for hiding this comment

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

little bit more

highlighted, err := h.Highlight(content, qs.Language, qs.Theme, qs.LineNr)
if err != nil {
// they should still be able to get the plain text even if the highlighter is b0rked
c.Status(http.StatusOK).Send([]byte(content))
Copy link
Member

Choose a reason for hiding this comment

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

if it's error, just return err, no need to make a StatusOK response

Copy link
Member Author

Choose a reason for hiding this comment

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

kalo highlighternya doang yg error, masa ga ditampilin meskipun ga pake highlight?

Copy link
Member

Choose a reason for hiding this comment

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

kemungkinan highlighternya error gara-gara apa?

Copy link
Member Author

Choose a reason for hiding this comment

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

gagal tokenise atau formatter gagal ngehasilin output

Copy link
Member

Choose a reason for hiding this comment

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

oke. tetep aja ga ideal. tapi aku benerin nantian

@@ -58,13 +58,18 @@ func (d *Dependency) Get(c *fiber.Ctx) error {
// we need to replace escaped newline to literal newline
content := strings.Replace(i.Paste, `\n`, "\n", -1)

c.Set("Content-Type", "text/plain")
Copy link
Member

Choose a reason for hiding this comment

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

the Content-Type headers will be set twice when qs.Language is not empty if you put it here

Copy link
Member Author

@elianiva elianiva Oct 5, 2021

Choose a reason for hiding this comment

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

alasan kenapa ditaruh disini relate sama ini #1 (comment), awalnya biar ga perlu copas, yowes lah

@aldy505 aldy505 merged commit 2917c74 into master Oct 5, 2021
@aldy505 aldy505 deleted the feat/chroma_highlight branch October 5, 2021 10:15
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.

2 participants