1
0
mirror of https://github.com/chubin/cheat.sh.git synced 2026-06-20 21:26:44 +02:00

added c++ support

This commit is contained in:
Igor Chubin
2017-07-25 17:41:22 +00:00
parent f3f69334db
commit 3602f2bde2
2 changed files with 34 additions and 0 deletions
+33
View File
@@ -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(),
+1
View File
@@ -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,