github-to-canvas 0.1.15 → 0.1.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -4
- data/README.md +18 -33
- data/lib/github-to-canvas.rb +1 -1
- data/lib/github-to-canvas/canvas_interface.rb +0 -1
- data/lib/github-to-canvas/repository_converter.rb +4 -50
- data/lib/github-to-canvas/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c22dc2963d6dd8ee12c704de58f8a82a636c24abcea448ae49d84f25e8aad3f1
|
4
|
+
data.tar.gz: b96b71607b765ba283829e0dc5912a5034a9a4e2e1898bb853a36e53e996e0b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb25c2e7cdcc0c06dd9a63f28b830e0cb7ae3248c0ad4d83f32de4039b9bb169a1a77c18f242b935ac5bf4fd3be950f23114b3354ac6125bed059f0adac17013
|
7
|
+
data.tar.gz: 62bcc1253d43a08ef2837d45f23eb781a6c80509f50ea5befe3711664e740db58d2770ee1652ca4f503e15b036187d2fd19c1d8884bbf73052edba76d7b4eaf8
|
data/Gemfile
CHANGED
@@ -1,11 +1,8 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
|
-
|
3
2
|
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
4
|
-
|
5
3
|
ruby "2.6.1"
|
6
|
-
|
7
4
|
gem 'require_all'
|
8
5
|
gem 'json'
|
9
6
|
gem 'redcarpet'
|
10
7
|
gem 'rest-client'
|
11
|
-
# Specify your gem's dependencies in github-to-canvas.gemspec
|
8
|
+
# Specify your gem's dependencies in github-to-canvas.gemspec
|
data/README.md
CHANGED
@@ -30,13 +30,13 @@ called `CANVAS_API_KEY`.
|
|
30
30
|
If you are using Zsh, the following command will add your new key to the top of `~/.zshrc`:
|
31
31
|
|
32
32
|
```sh
|
33
|
-
echo "$(export 'CANVAS_API_KEY
|
33
|
+
echo "$(export 'CANVAS_API_KEY=<your-new-API-key-here>' | cat - ~/.zshrc)" > ~/.zshrc
|
34
34
|
```
|
35
35
|
|
36
36
|
If you are using Bash, use this command instead:
|
37
37
|
|
38
38
|
```sh
|
39
|
-
echo "$(export 'CANVAS_API_KEY
|
39
|
+
echo "$(export 'CANVAS_API_KEY=<your-new-API-key-here>' | cat - ~/.bash_profile)" > ~/.bash_profile
|
40
40
|
```
|
41
41
|
|
42
42
|
> If you aren't sure which you use, run `echo $SHELL`
|
@@ -294,45 +294,30 @@ includes HTML that is not meant to be rendered, the content will be rendered as
|
|
294
294
|
part of the page's HTML, resulting in unusual display errors in Canvas. Examples of
|
295
295
|
this would be lessons on HTML or JavaScript that include HTML code snippets.
|
296
296
|
|
297
|
-
To
|
298
|
-
|
299
|
-
|
300
|
-
the HTML.
|
297
|
+
To fix any rendering issues in Canvas, go to the Canvas WYSIWYG editor for the
|
298
|
+
afflicted lesson. Click the HTML editor option (`</>` button in the lower right) to
|
299
|
+
switch to HTML.
|
301
300
|
|
302
|
-
|
303
|
-
you will need to either replace HTML that you want to be rendered with markdown
|
304
|
-
syntax equivalents. For example, HTML you want to display as code and an `<img>`
|
305
|
-
element you want to render as the image itself, replace the `<img>` tag with
|
306
|
-
markdown syntax (`![alt text](url)`).
|
301
|
+
Read the GitHub repo as HTML:
|
307
302
|
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
If you have HTML related rendering issues in Canvas that can't be fixed with
|
313
|
-
`--contains-html`:
|
314
|
-
|
315
|
-
- Go to the Canvas WYSIWYG editor for the afflicted lesson.
|
316
|
-
- Click the HTML editor option (`</>` button in the lower right) to switch to
|
317
|
-
HTML.
|
318
|
-
- Read the GitHub repo as HTML:
|
319
|
-
|
320
|
-
```sh
|
321
|
-
github-to-canvas --read-from-github URL
|
322
|
-
```
|
303
|
+
```sh
|
304
|
+
github-to-canvas --read-from-github URL
|
305
|
+
```
|
323
306
|
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
307
|
+
Copy the output HTML and paste it into the Canvas editor (if your lesson has a
|
308
|
+
`<header>` with github links, leave this in). This should clear up some larger
|
309
|
+
page rendering issues, but may not fix all code snippets issues. To fix these,
|
310
|
+
switch back to the regular Canvas WYSIWYG editor, then open a second tab to the
|
311
|
+
GitHub repo you're converting from. Copy any HTML code snippets from GitHub and
|
312
|
+
paste them into the Canvas editor where they should be displayed.
|
330
313
|
|
331
314
|
The Canvas editor will treat the pasted HTML content as code and will
|
332
315
|
automatically replace some characters, escaping the code from the
|
333
316
|
normal rendering process.
|
334
317
|
|
335
|
-
Note that realigning after fixing this content
|
318
|
+
Note that realigning after fixing this content with the gem will break the
|
319
|
+
rendering for these lessons again. A fix is planned for this issue, but has not
|
320
|
+
been implemented.
|
336
321
|
|
337
322
|
### Multi-Line Code Snippets Render as a Single Line
|
338
323
|
|
data/lib/github-to-canvas.rb
CHANGED
@@ -23,7 +23,7 @@ class GithubToCanvas
|
|
23
23
|
when 'map'
|
24
24
|
CanvasInterface.map_course_info(options)
|
25
25
|
when 'csv'
|
26
|
-
CanvasInterface.csv(options[:file_to_convert])
|
26
|
+
CanvasInterface.csv(options[:file_to_convert]) # not working properly
|
27
27
|
when 'canvas_read'
|
28
28
|
puts CanvasInterface.read_lesson(options[:filepath])
|
29
29
|
when 'canvas_copy'
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'redcarpet'
|
2
|
-
require 'byebug'
|
3
2
|
class CustomRender < Redcarpet::Render::HTML
|
4
3
|
def block_code(code, lang)
|
5
4
|
"<pre>" \
|
@@ -51,7 +50,6 @@ class RepositoryConverter
|
|
51
50
|
end
|
52
51
|
|
53
52
|
def self.adjust_converted_html(options, html)
|
54
|
-
|
55
53
|
if options[:remove_header_and_footer]
|
56
54
|
html = self.remove_header_and_footer(html)
|
57
55
|
end
|
@@ -63,70 +61,26 @@ class RepositoryConverter
|
|
63
61
|
if options[:contains_html]
|
64
62
|
html = self.fix_escaped_inline_html_code(html)
|
65
63
|
end
|
66
|
-
|
67
64
|
html
|
68
65
|
end
|
69
66
|
|
70
67
|
def self.fix_escaped_inline_html_code(html)
|
71
68
|
|
72
|
-
# stops HTML/JSX code blocks from rendering as HTML in Canvas
|
73
|
-
# html = html.gsub("&gt;</code>", "></code>")
|
74
|
-
# html = html.gsub("&gt;</code>", "></code>")
|
75
|
-
|
76
|
-
# fixes < and > code snippets
|
77
|
-
|
78
|
-
# html = html.gsub(/<pre><code>(.*?)<\/code><\/pre>/) { |string|
|
79
|
-
# byebug
|
80
|
-
# }
|
81
|
-
# html = html.gsub("&gt;", ">")
|
82
|
-
|
83
|
-
# # fixes blockquotes
|
84
|
-
# html = html.gsub(/\n<p>>\;(.*)\n>\;/) { |bq|
|
85
|
-
# bq.delete_prefix!("\n<p>>")
|
86
|
-
# "\n<blockquote>" + bq
|
87
|
-
# }
|
88
|
-
# html = html.gsub(/\n>\;(.*)\n>\;/) { |bq|
|
89
|
-
# bq.delete_prefix!("\n>")
|
90
|
-
# " " + bq
|
91
|
-
# }
|
92
|
-
# html = html.gsub(/\n>\;(.*)<\/p>/) { |bq|
|
93
|
-
# bq.delete_prefix!("\n>\;")
|
94
|
-
# bq.delete_suffix!("</p>")
|
95
|
-
# " " + bq + "</blockquote>"
|
96
|
-
# }
|
97
|
-
|
98
69
|
html
|
99
70
|
end
|
100
71
|
|
101
|
-
|
102
72
|
def self.escape_existing_html(markdown)
|
103
|
-
markdown = markdown.gsub(/```(\n|.)
|
104
|
-
# all blocks
|
73
|
+
markdown = markdown.gsub(/```(\n|.)*?```/) { |code|
|
74
|
+
# all code blocks
|
105
75
|
code = code.gsub("<", "<")
|
106
76
|
code = code.gsub(">", ">")
|
107
77
|
}
|
108
|
-
# markdown = markdown.gsub(/(`)(.+?)(`)/) { |code|
|
109
|
-
# # all backticks
|
110
|
-
|
111
|
-
# if code.match?(/<(.*?)>/)
|
112
|
-
# code = code.gsub("<", "<")
|
113
|
-
# code = code.gsub(">", ">")
|
114
|
-
# end
|
115
|
-
|
116
|
-
# code
|
117
|
-
# }
|
118
|
-
# markdown = markdown.gsub(/<(?!iframe)/, "<")
|
119
|
-
# markdown = markdown.gsub(/(?<!iframe)>/, ">")
|
120
|
-
|
121
|
-
# markdown = markdown.gsub(/```(.*?)```/) {|s|
|
122
|
-
# byebug
|
123
|
-
# }
|
124
78
|
markdown
|
125
79
|
end
|
126
80
|
|
127
81
|
def self.remove_header_and_footer(html)
|
128
82
|
new_html = self.remove_html_header(html)
|
129
|
-
new_html = self.remove_footer(new_html)
|
83
|
+
# new_html = self.remove_footer(new_html)
|
130
84
|
new_html
|
131
85
|
end
|
132
86
|
|
@@ -143,7 +97,7 @@ class RepositoryConverter
|
|
143
97
|
end
|
144
98
|
|
145
99
|
def self.remove_html_header(html)
|
146
|
-
html.gsub(/<h1
|
100
|
+
html.gsub(/<h1>.*?<\/h1>/,"")
|
147
101
|
end
|
148
102
|
|
149
103
|
def self.fix_local_html_links(options, html, filepath)
|