codimd icon indicating copy to clipboard operation
codimd copied to clipboard

Makefile syntax highlight

Open yangyang95 opened this issue 8 years ago • 10 comments
trafficstars

It would be great if makefile highlighting is supported in code block.

yangyang95 avatar Mar 25 '17 02:03 yangyang95

Thanks @yangyang95 Makefile is popular format , we will support it.

a60814billy avatar Mar 25 '17 07:03 a60814billy

That's a good news. Thanks a lot.

yangyang95 avatar Mar 25 '17 07:03 yangyang95

I found we have already support makefile syntax highlighting. Please use cmake in the code block language.

jackycute avatar Mar 26 '17 14:03 jackycute

This is what I got using cmake, code block at right doesn't display properly. make And it would be better if the code display same as the Prism which I know hackmd is using.

Attached the code here for testing

ifeq ($(strip $(THREAD_TEST)),1)
CFLAGS_opt  += -D THREAD_TEST
endif

thread_test: main.c
	for i in `seq 1 128`; \
	do $(MAKE) phonebook_opt THREAD_TEST=1 THREAD=$$i --silent; \
	./phonebook_opt; echo "\n"; \
	rm -rf phonebook_opt; \
	done;

And I found out github display it good, too. lol Thanks.

yangyang95 avatar Mar 26 '17 14:03 yangyang95

@yangyang95 Actually we use both highlight.js and Prism both for different code languages. Shame on highlight.js not handle that properly, you could raise a issue for them. I will change the cmake highlighting to Prism for now.

jackycute avatar Mar 26 '17 14:03 jackycute

Changed in b2985085d011cad374c76ae75f548fdefb15c258

jackycute avatar Mar 26 '17 15:03 jackycute

Oh, mind that cmake and makefile seems to be different. Though I had no idea, since I have never used cmake. reference:

yangyang95 avatar Mar 26 '17 15:03 yangyang95

Hmm, but our editor CodeMirror seems only support cmake in the official release. highlight.js supports cmake and makefile. Prism supports only makefile.

This should be consider again.

jackycute avatar Mar 26 '17 15:03 jackycute

This might able to give us some hint https://github.com/notepadqq/CodeMirror/blob/d790fc39c1a5f06aa66415110b8ebe3026df665a/mode/makefile/makefile.js

jackycute avatar Mar 27 '17 06:03 jackycute

Makefile highlighting has different appearances in editor view mode and in production view mode.

Here is the code for testing:

```makefile
$(CC) -c $(CPPFLAGS) $(CFLAGS)
```

In editor view mode, it looks like this: image

While in production view mode, it looks like this: image

wdzeng avatar Feb 04 '22 14:02 wdzeng