github-to-canvas 0.1.11 → 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: 25c87f7d039c5d682c061bd089500daa36fbc17944f2b396b7e4e4d09d54d071
4
- data.tar.gz: f30fae04f6ce01b02b9fb8462eae2bee98504cfcb24a5f56a6642c8cd971d068
3
+ metadata.gz: c22dc2963d6dd8ee12c704de58f8a82a636c24abcea448ae49d84f25e8aad3f1
4
+ data.tar.gz: b96b71607b765ba283829e0dc5912a5034a9a4e2e1898bb853a36e53e996e0b3
5
5
  SHA512:
6
- metadata.gz: f04b54f431b6a6c9b786ec8b4542a3a7f488eadf2c3adb632369e3da38522d38bbb7f51d07ebafee759140421bbf932a5e9f834fbe82a094d637f7ba92c5f86a
7
- data.tar.gz: 7ad2efd5ddb65d660cb3c0d12fb11d14cac39d2b1495e0eb2eb5e7b73ca8c711fc0064b84f3ef2eb0d7bdd09bd547a95b703832edfbacbb454962caabab38585
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)
@@ -98,7 +97,6 @@ class CanvasInterface
98
97
  lesson_info = lesson_info[0] if lesson_info.kind_of?(Array)
99
98
  url = url.sub(/[^\/]+$/, lesson_info["page_id"].to_s)
100
99
  end
101
-
102
100
  response = RestClient.put(url, payload, headers)
103
101
  rescue Exception => e
104
102
  puts "Something went wrong while pushing lesson #{options[:id]} to course #{options[:course_id]}"
@@ -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,55 +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(/<\/(?!iframe)/, "&lt;/")
104
- # markdown = markdown.gsub(/<(?!iframe)/, "&lt;")
105
- # markdown = markdown.gsub(/(?<!iframe)>/, "&gt;")
106
- # byebug
107
- # markdown = markdown.gsub(/```(.*?)```/) {|s|
108
- # byebug
109
- # }
73
+ markdown = markdown.gsub(/```(\n|.)*?```/) { |code|
74
+ # all code blocks
75
+ code = code.gsub("<", "&lt;")
76
+ code = code.gsub(">", "&gt;")
77
+ }
78
+ markdown
110
79
  end
111
80
 
112
81
  def self.remove_header_and_footer(html)
113
82
  new_html = self.remove_html_header(html)
114
- new_html = self.remove_footer(new_html)
83
+ # new_html = self.remove_footer(new_html)
115
84
  new_html
116
85
  end
117
86
 
@@ -128,7 +97,7 @@ class RepositoryConverter
128
97
  end
129
98
 
130
99
  def self.remove_html_header(html)
131
- html.gsub(/<h1>.*<\/h1>/,"")
100
+ html.gsub(/<h1>.*?<\/h1>/,"")
132
101
  end
133
102
 
134
103
  def self.fix_local_html_links(options, html, filepath)
@@ -1,3 +1,3 @@
1
1
  class GithubToCanvas
2
- VERSION = "0.1.11"
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.11
4
+ version: 0.1.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - maxwellbenton