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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2fdb3495cf035026b326415c643f799389f104d417f3131504bc173756f6139b
4
- data.tar.gz: 1e33feb5268015f1db19089686fe8c10299ec925f2b49c2c4a1f9b759fe5092f
3
+ metadata.gz: c22dc2963d6dd8ee12c704de58f8a82a636c24abcea448ae49d84f25e8aad3f1
4
+ data.tar.gz: b96b71607b765ba283829e0dc5912a5034a9a4e2e1898bb853a36e53e996e0b3
5
5
  SHA512:
6
- metadata.gz: 4e3db83d774f1b815faf65f09b7cb63b2e76a04c80eef1671b1bf2130540a387ed89333556fc96257e56862885a3ce83670ebeb4094abd142e83b50c5dae3a5f
7
- data.tar.gz: abe6c2dbd1ccc1e710f5ca9e32bfba5dadb7e1651ed03656115b3db1cbfc11b378d12f224a075952c87ada6411c2f989e401504290d0c8a71748adf664eef216
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=your-new-API-key-here' | cat - ~/.zshrc)" > ~/.zshrc
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=your-new-API-key-here' | cat - ~/.bash_profile)" > ~/.bash_profile
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 prevent HTML from being rendered, include the `--contains-html` option when
298
- running the GitHub to Canvas gem. This replaces `<` and `>` characters with HTML
299
- charset values wrapped in `span` elements. This will stop Canvas from rendering
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
- If your markdown contains a mix of HTML that should and should not be rendered,
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
- The one exception is the `<iframe>` element. There is no way to easily embed
309
- videos in GitHub markdown without HTML, so this tag will always be allowed to
310
- render in Canvas, whether or not you use `--contains-html`.
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
- - Copy the output HTML and paste it in to the Canvas editor. This should clear up
325
- some larger page rendering issues, but may not fix all code snippets issues.
326
- - Switch back to the regular Canvas WYSIWYG editor
327
- - Open a second tab to the GitHub repo you're converting from.
328
- - Copy any HTML code snippets from GitHub and paste them into the Canvas editor
329
- where they should be displayed.
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 may overwrite fixes.
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
 
@@ -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,7 +1,6 @@
1
1
  require 'json'
2
2
  require 'rest-client'
3
3
  require 'yaml'
4
- # require 'byebug'
5
4
  class CanvasInterface
6
5
 
7
6
  def self.create_course(course_info)
@@ -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("&amp;gt;</code>", "&gt;</code>")
74
- # html = html.gsub("&amp;gt;</code>", "&gt;</code>")
75
-
76
- # fixes < and > code snippets
77
-
78
- # html = html.gsub(/<pre><code>(.*?)<\/code><\/pre>/) { |string|
79
- # byebug
80
- # }
81
- # html = html.gsub("&amp;gt;", "&gt;")
82
-
83
- # # fixes blockquotes
84
- # html = html.gsub(/\n<p>&gt\;(.*)\n&gt\;/) { |bq|
85
- # bq.delete_prefix!("\n<p>&gt;")
86
- # "\n<blockquote>" + bq
87
- # }
88
- # html = html.gsub(/\n&gt\;(.*)\n&gt\;/) { |bq|
89
- # bq.delete_prefix!("\n&gt;")
90
- # " " + bq
91
- # }
92
- # html = html.gsub(/\n&gt\;(.*)<\/p>/) { |bq|
93
- # bq.delete_prefix!("\n&gt\;")
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|.)*```/) { |code|
104
- # all blocks
73
+ markdown = markdown.gsub(/```(\n|.)*?```/) { |code|
74
+ # all code blocks
105
75
  code = code.gsub("<", "&lt;")
106
76
  code = code.gsub(">", "&gt;")
107
77
  }
108
- # markdown = markdown.gsub(/(`)(.+?)(`)/) { |code|
109
- # # all backticks
110
-
111
- # if code.match?(/<(.*?)>/)
112
- # code = code.gsub("<", "&lt;")
113
- # code = code.gsub(">", "&gt;")
114
- # end
115
-
116
- # code
117
- # }
118
- # markdown = markdown.gsub(/<(?!iframe)/, "&lt;")
119
- # markdown = markdown.gsub(/(?<!iframe)>/, "&gt;")
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>.*<\/h1>/,"")
100
+ html.gsub(/<h1>.*?<\/h1>/,"")
147
101
  end
148
102
 
149
103
  def self.fix_local_html_links(options, html, filepath)
@@ -1,3 +1,3 @@
1
1
  class GithubToCanvas
2
- VERSION = "0.1.15"
2
+ VERSION = "0.1.16"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github-to-canvas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.15
4
+ version: 0.1.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - maxwellbenton