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

[WIP] #21: highlight code blocks #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

timmhirsens
Copy link
Owner

Beginning working on highlighting code blocks.

This will close #21

There are some 'edge' cases that currently are unsupported:

  def call(%Plug.Conn{} = conn, []),
    do: conn # <- do: on next line after def
  def clear_session(conn) do
    put_session(conn, fn(_existing) -> Map.new end) # end on same line as fn ->
  end
def code(integer_or_atom) # function declaration w/o body
  def call(conn, level) do
    Logger.log level, fn ->
      [conn.method, ?\s, conn.request_path]
    end

    start = current_time()

    Conn.register_before_send(conn, fn conn ->
      Logger.log level, fn ->
        stop = current_time()
        diff = time_diff(start, stop)

        [connection_type(conn), ?\s, Integer.to_string(conn.status),
         " in ", formatted_diff(diff)]
      end
      conn
    end) # <- 'end' with trailing ')'
  end

In my simple phoenix application it does work pretty well at the moment.
But I think before releasing this, those edge cases should be handled.

Beginning working on highlighting code blocks.
@konradkalita
Copy link

@fr1zle Hi, are you still interested in this feature? I could solve these edge cases for you.

@timmhirsens
Copy link
Owner Author

Sure, feel free to pickup from here or open up a new PR

@konradkalita
Copy link

I digged into it and I conclude that to do it well I need an elixir parser or at least a lexer. Unfortunately number of constructs like many kind of strings, comments, sigils, atoms which I should exclude to find proper keyword is to big. Do you know if I can get a parse tree/ast with position annotations from Elixir Sense?

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

Successfully merging this pull request may close these issues.

Highlight start of code block when selecting the end, and vice versa
2 participants