mirror of
https://github.com/chubin/cheat.sh.git
synced 2026-06-20 13:16:44 +02:00
added c++ support
This commit is contained in:
@@ -118,6 +118,38 @@ class LearnClojureAdapter(LearnXYAdapter):
|
||||
answer = answer[:1]
|
||||
return answer
|
||||
|
||||
class LearnCppAdapter(LearnXYAdapter):
|
||||
_prefix = "c++"
|
||||
_filename = "c++.html.markdown"
|
||||
|
||||
def _is_block_separator(self, before, now, after):
|
||||
if ( re.match(r'////////*', before)
|
||||
and re.match(r'// ', now)
|
||||
and re.match(r'////////*', after)):
|
||||
block_name = re.sub('//\s*', '', now).replace('(', '').replace(')', '')
|
||||
block_name = '_'.join(block_name.strip(", ").split())
|
||||
replace_with = {
|
||||
'More_about_Objects':
|
||||
'Prototypes',
|
||||
}
|
||||
for k in replace_with:
|
||||
if k in block_name:
|
||||
block_name = replace_with[k]
|
||||
return block_name
|
||||
else:
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def _cut_block(block):
|
||||
answer = block[2:-1]
|
||||
if answer == []:
|
||||
return answer
|
||||
if answer[0].split() == '':
|
||||
answer = answer[1:]
|
||||
if answer[-1].split() == '':
|
||||
answer = answer[:1]
|
||||
return answer
|
||||
|
||||
class LearnElixirAdapter(LearnXYAdapter):
|
||||
_prefix = "elixir"
|
||||
_filename = "elixir.html.markdown"
|
||||
@@ -487,6 +519,7 @@ class LearnRubyAdapter(LearnXYAdapter):
|
||||
|
||||
ADAPTERS = {
|
||||
'clojure' : LearnClojureAdapter(),
|
||||
'cpp' : LearnCppAdapter(),
|
||||
'elixir' : LearnElixirAdapter(),
|
||||
'elm' : LearnElmAdapter(),
|
||||
'erlang' : LearnErlangAdapter(),
|
||||
|
||||
@@ -39,6 +39,7 @@ from adapter_learnxiny import get_learnxiny, get_learnxiny_list, is_valid_learnx
|
||||
INTERNAL_TOPICS = [":list", ":firstpage", ':post', ':bash_completion', ':help', ':styles', ':styles-demo', ':emacs', ':emacs-ivy', ':fish', ':bash', ':zsh']
|
||||
LEXER = {
|
||||
"clojure": pygments.lexers.ClojureLexer,
|
||||
"cpp" : pygments.lexers.CppLexer,
|
||||
"erlang": pygments.lexers.ErlangLexer,
|
||||
"elixir": pygments.lexers.ElixirLexer,
|
||||
"elm" : pygments.lexers.ElmLexer,
|
||||
|
||||
Reference in New Issue
Block a user