List for cgit developers and users
 help / color / mirror / Atom feed
* Fwd: Re: RESEND: syntax-highlighting.py
       [not found] <52CD7ADF.2080903@sevenbyte.org>
@ 2014-01-08 16:22 ` stefan
  2014-01-08 16:28   ` Jason
  0 siblings, 1 reply; 3+ messages in thread
From: stefan @ 2014-01-08 16:22 UTC (permalink / raw)


Am 08.01.2014 16:19, schrieb Jason A. Donenfeld:
> Okay reading this closer, it seems what the one in-tree could benefit from is:
> 
> - Expanded list of filename mappings, made more generic than what you
> have in your script, but basically the same idea. -- { "pkgbuild":
> "bashlexer", "cmakelists.txt", "cmakelexer" }. Is there a way to do
> this that ties directly into pygment's guess_lexer_for_filename? If
> not, could you submit a patch upstream?

I have looked in pygment's sourcecode and found this [0]. I just have to
add the filenames in the lexer definitions. I will try to create an
upstream pull request. The only problem is that the latest release of
pygments is almost 1 year old. It think it will take a while until the
changes get merged...

As a workaround we could create such a dict as you suggested and check
if the filenames match.

> - We should make use of guess_lexer as you do, but perhaps not only if
> the shebang is present

At first I run guess_lexer_for_filename (line 26). It checks the content
of the file and also looks at the filename. After that I check if there
is a shebang because the script has already looked at the content with
guess_lexer_for_filename. I have tested this without the shebang
detection and especially with plaintext files it often returns crap...

> Would love for a patch against the in-tree version that gets it up to
> date like this.

:-)
It will take a few days because currently I have exams... Should I work
on the master branch or something else?

What do you want to de with the CSS definitions? Just put them into the
default cgit CSS file or maybe include it seperately?

Stefan

Links:
[0]:
https://bitbucket.org/birkenfeld/pygments-main/src/9246d7a47a42e7920c0ecee4d4946b982e9e2430/pygments/lexers/_mapping.py?at=default





-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: OpenPGP digital signature
URL: <http://lists.zx2c4.com/pipermail/cgit/attachments/20140108/d242b74e/attachment.asc>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RESEND: syntax-highlighting.py
  2014-01-08 16:22 ` Fwd: Re: RESEND: syntax-highlighting.py stefan
@ 2014-01-08 16:28   ` Jason
  2014-01-09 19:52     ` stefan
  0 siblings, 1 reply; 3+ messages in thread
From: Jason @ 2014-01-08 16:28 UTC (permalink / raw)


On Wed, Jan 8, 2014 at 5:22 PM, Stefan Tatschner <stefan at sevenbyte.org> wrote:
> I have looked in pygment's sourcecode and found this [0]. I just have to
> add the filenames in the lexer definitions. I will try to create an
> upstream pull request. The only problem is that the latest release of
> pygments is almost 1 year old. It think it will take a while until the
> changes get merged...
>
> As a workaround we could create such a dict as you suggested and check
> if the filenames match.

Another workaround might be just to monkey patch _mapping.LEXERS. Any
of these possibilities is probably fine.


> At first I run guess_lexer_for_filename (line 26). It checks the content
> of the file and also looks at the filename. After that I check if there
> is a shebang because the script has already looked at the content with
> guess_lexer_for_filename. I have tested this without the shebang
> detection and especially with plaintext files it often returns crap...

Okay fair enough. Shebang guessing only.


> It will take a few days because currently I have exams... Should I work
> on the master branch or something else?

Yes the master branch.

>
> What do you want to de with the CSS definitions? Just put them into the
> default cgit CSS file or maybe include it seperately?

We already handle that on line 34 of [1], so no need to do anything
differently. Please base your work off [1] generally.


Thanks a bunch! Looking forward to seeing the results.

Jason

[1] http://git.zx2c4.com/cgit/tree/filters/syntax-highlighting.py


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RESEND: syntax-highlighting.py
  2014-01-08 16:28   ` Jason
@ 2014-01-09 19:52     ` stefan
  0 siblings, 0 replies; 3+ messages in thread
From: stefan @ 2014-01-09 19:52 UTC (permalink / raw)


Am 08.01.2014 17:28, schrieb Jason A. Donenfeld:
>> What do you want to de with the CSS definitions? Just put them into the
>> default cgit CSS file or maybe include it seperately?
> 
> We already handle that on line 34 of [1], so no need to do anything
> differently. Please base your work off [1] generally.
>
> [1] http://git.zx2c4.com/cgit/tree/filters/syntax-highlighting.py

Actually I do not like this implementation of CSS output in the script.
In the final HTML output there is something like this:

<td class='lines'><pre><code><style>.highlight .hll { background-color:
#ffffcc }
.highlight  { background: #ffffff; }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 }

[...]

</style><div class="highlight"><pre>

You see the CSS definitions for the synthax highlighting thing come
within a table within a pre within a code tag. I do not think this is
the right place for CSS definitions.

What do you think?

Stefan

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: OpenPGP digital signature
URL: <http://lists.zx2c4.com/pipermail/cgit/attachments/20140109/f76b1af2/attachment.asc>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-01-09 19:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <52CD7ADF.2080903@sevenbyte.org>
2014-01-08 16:22 ` Fwd: Re: RESEND: syntax-highlighting.py stefan
2014-01-08 16:28   ` Jason
2014-01-09 19:52     ` stefan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).