class_docstr: The Presentation class for creating spectacle-presentations.
  
  The Presentations API is a means for creating JSON blobs which are then
  converted Spectacle Presentations. To use the API you only need to define
  a block string and define your slides using markdown. Then you can upload
  your presentation to the Plotly Server.
  
  Rules for your presentation string:
  - use '---' to denote a slide break.
  - headers work as per usual, where if '#' is used before a line of text
    then it is interpretted as a header. Only the first header in a slide is
    displayed on the slide. There are only 3 heading sizes: #, ## and ###.
    4 or more hashes will be interpretted as ###.
  - you can set the type of slide transition you want by writing a line that
    starts with 'transition: ' before your first header line in the slide,
    and write the types of transition you want after. Your transition to
    choose from are 'slide',  'zoom', 'fade' and 'spin'.
  - to insert a Plotly chart into your slide, write a line that has the form
    Plotly(url) with your url pointing to your chart. Note that it is
    STRONGLY advised that your chart has fig['layout']['autosize'] = True.
  - to insert an image from the web, write a line with the form Image(url)
  - to insert a block of text, begin with a line that denotes the code
    envoronment '```lang' where lang is a valid programming language. To find
    the valid languages run:
  
    'plotly.presentation_objs.presentation_objs.VALID_LANGUAGES'
  
    To end the code block environment,
    write a single '```' line. All Plotly(url) and Image(url) lines will NOT
    be interpretted as a Plotly or Image url if they are in the code block.
  
  :param (str) markdown_string: the block string that denotes the slides,
      slide properties, and images to be placed in the presentation. If
      'markdown_string' is set to 'None', the JSON for a presentation with
      one empty slide will be created.
  :param (str) style: the theme that the presentation will take on. The
      themes that are available now are 'martik' and 'moods'.
      Default = 'moods'.
  :param (bool) imgStretch: if set to False, all images in the presentation
      will not have heights and widths that will not exceed the parent
      container they belong to. In other words, images will keep their
      original aspect ratios.
      Default = True.
  
  For examples see the documentation:
  
  https://plotly.com/python/presentations-api/
class_docstr_tok: ["The","Presentation","class","for","creating","spectacle-presentations",".","The","Presentations","API","is","a","means","for","creating","JSON","blobs","which","are","then","converted","Spectacle","Presentations",".","To","use","the","API","you","only","need","to","define","a","block","string","and","define","your","slides","using","markdown",".","Then","you","can","upload","your","presentation","to","the","Plotly","Server",".","Rules","for","your","presentation","string",":","-","use","'","--","-","'","to","denote","a","slide","break",".","-","headers","work","as","per","usual",",","where","if","'","#","'","is","used","before","a","line","of","text","then","it","is","interpretted","as","a","header",".","Only","the","first","header","in","a","slide","is","displayed","on","the","slide",".","There","are","only","3","heading","sizes",":","#",",","#","#","and","#","#","#",".","4","or","more","hashes","will","be","interpretted","as","#","#","#",".","-","you","can","set","the","type","of","slide","transition","you","want","by","writing","a","line","that","starts","with","'transition",":","'","before","your","first","header","line","in","the","slide",",","and","write","the","types","of","transition","you","want","after",".","Your","transition","to","choose","from","are","'slide","'",",","'zoom","'",",","'fade","'","and","'spin","'",".","-","to","insert","a","Plotly","chart","into","your","slide",",","write","a","line","that","has","the","form","Plotly","(","url",")","with","your","url","pointing","to","your","chart",".","Note","that","it","is","STRONGLY","advised","that","your","chart","has","fig","[","'layout","'","]","[","'autosize","'","]","=","True",".","-","to","insert","an","image","from","the","web",",","write","a","line","with","the","form","Image","(","url",")","-","to","insert","a","block","of","text",",","begin","with","a","line","that","denotes","the","code","envoronment","'","``","`","lang","'","where","lang","is","a","valid","programming","language",".","To","find","the","valid","languages","run",":","'plotly.presentation_objs.presentation_objs.VALID_LANGUAGES'","To","end","the","code","block","environment",",","write","a","single","'","``","`","'","line",".","All","Plotly","(","url",")","and","Image","(","url",")","lines","will","NOT","be","interpretted","as","a","Plotly","or","Image","url","if","they","are","in","the","code","block",".",":","param","(","str",")","markdown_string",":","the","block","string","that","denotes","the","slides",",","slide","properties",",","and","images","to","be","placed","in","the","presentation",".","If","'markdown_string","'","is","set","to","'None","'",",","the","JSON","for","a","presentation","with","one","empty","slide","will","be","created",".",":","param","(","str",")","style",":","the","theme","that","the","presentation","will","take","on",".","The","themes","that","are","available","now","are","'martik","'","and","'moods","'",".","Default","=","'moods","'",".",":","param","(","bool",")","imgStretch",":","if","set","to","False",",","all","images","in","the","presentation","will","not","have","heights","and","widths","that","will","not","exceed","the","parent","container","they","belong","to",".","In","other","words",",","images","will","keep","their","original","aspect","ratios",".","Default","=","True",".","For","examples","see","the","documentation",":","https",":","\/\/plotly.com\/python\/presentations-api\/"]
code: def _markdown_to_presentation(
      self, markdown_string, style, imgStretch
  ):
      list_of_slides = _list_of_slides(markdown_string)
  
      for slide_num, slide in enumerate(list_of_slides):
          lines_in_slide = slide.split("\n")
          title_lines = []
  
          # validate blocks of code
          if slide.count("```") % 2 != 0:
              raise _plotly_utils.exceptions.PlotlyError(CODE_ENV_ERROR)
  
          # find code blocks
          code_indices = []
          code_blocks = []
          wdw_size = len("```")
          for j in range(len(slide)):
              if slide[j : j + wdw_size] == "```":
                  code_indices.append(j)
  
          for k in range(int(len(code_indices) / 2)):
              code_blocks.append(
                  slide[code_indices[2 * k] : code_indices[(2 * k) + 1]]
              )
  
          lang_and_code_tuples = []
          for code_block in code_blocks:
              # validate code blocks
              code_by_lines = code_block.split("\n")
              language = _remove_extra_whitespace_from_line(
                  code_by_lines[0][3:]
              ).lower()
              if language == "" or language not in VALID_LANGUAGES:
                  raise _plotly_utils.exceptions.PlotlyError(
                      "The language of your code block should be "
                      "clearly indicated after the first ``` that "
                      "begins the code block. The valid languages to "
                      "choose from are"
                      + list_of_options(VALID_LANGUAGES)
                  )
              lang_and_code_tuples.append(
                  (language, "\n".join(code_by_lines[1:]))
              )
  
          # collect text, code and urls
          title_lines = []
          url_lines = []
          text_lines = []
          inCode = False
  
          for line in lines_in_slide:
              # inCode handling
              if line[:3] == "```" and len(line) > 3:
                  inCode = True
              if line == "```":
                  inCode = False
  
              if not inCode and line != "```":
                  if len(line) > 0 and line[0] == "#":
                      title_lines.append(line)
                  elif _url_parens_contained(
                      "Plotly", line
                  ) or _url_parens_contained("Image", line):
                      if (
                          line.startswith("Plotly(")
                          and get_config()["plotly_domain"] not in line
                      ):
                          raise _plotly_utils.exceptions.PlotlyError(
                              "You are attempting to insert a Plotly Chart "
                              "in your slide but your url does not have "
                              "your plotly domain '{}' in it.".format(
                                  get_config()["plotly_domain"]
                              )
                          )
                      url_lines.append(line)
                  else:
                      # find and set transition properties
                      trans = "transition:"
                      if line.startswith(trans) and title_lines == []:
                          slide_trans = line[len(trans) :]
                          slide_trans = (
                              _remove_extra_whitespace_from_line(
                                  slide_trans
                              )
                          )
                          slide_transition_list = []
                          for key in VALID_TRANSITIONS:
                              if key in slide_trans:
                                  slide_transition_list.append(key)
  
                          if slide_transition_list == []:
                              slide_transition_list.append("slide")
                          self._set_transition(
                              slide_transition_list, slide_num
                          )
  
                      else:
                          text_lines.append(line)
  
          # make text block
          for i in range(2):
              try:
                  while text_lines[-i] == "":
                      text_lines.pop(-i)
              except IndexError:
                  pass
  
          text_block = "\n".join(text_lines)
          num_of_boxes = len(url_lines) + len(lang_and_code_tuples)
  
          (
              specs_for_boxes,
              specs_for_title,
              specs_for_text,
              bkgd_color,
              title_style_attr,
              text_style_attr,
              code_theme,
          ) = _return_layout_specs(
              num_of_boxes,
              url_lines,
              title_lines,
              text_block,
              code_blocks,
              slide_num,
              style,
          )
  
          # background color
          self._color_background(bkgd_color, slide_num)
  
          # insert title, text, code, and images
          if len(title_lines) > 0:
              # clean titles
              title = title_lines[0]
              num_hashes = 0
              while title[0] == "#":
                  title = title[1:]
                  num_hashes += 1
              title = _remove_extra_whitespace_from_line(title)
  
              self._insert(
                  box="Text",
                  text_or_url=title,
                  left=specs_for_title[0],
                  top=specs_for_title[1],
                  height=specs_for_title[2],
                  width=specs_for_title[3],
                  slide=slide_num,
                  style_attr=title_style_attr,
                  paragraphStyle="Heading 1".format(min(num_hashes, 3)),
              )
  
          # text
          if len(text_lines) > 0:
              self._insert(
                  box="Text",
                  text_or_url=text_block,
                  left=specs_for_text[0],
                  top=specs_for_text[1],
                  height=specs_for_text[2],
                  width=specs_for_text[3],
                  slide=slide_num,
                  style_attr=text_style_attr,
                  paragraphStyle="Body",
              )
  
          url_and_code_blocks = list(url_lines + lang_and_code_tuples)
          for k, specs in enumerate(specs_for_boxes):
              url_or_code = url_and_code_blocks[k]
              if isinstance(url_or_code, tuple):
                  # code
                  language = url_or_code[0]
                  code = url_or_code[1]
                  box_name = "CodePane"
  
                  # code style
                  props_attr = {}
                  props_attr["language"] = language
                  props_attr["theme"] = code_theme
  
                  self._insert(
                      box=box_name,
                      text_or_url=code,
                      left=specs[0],
                      top=specs[1],
                      height=specs[2],
                      width=specs[3],
                      slide=slide_num,
                      props_attr=props_attr,
                  )
              else:
                  # url
                  if get_config()["plotly_domain"] in url_or_code:
                      box_name = "Plotly"
                  else:
                      box_name = "Image"
                  url = url_or_code[len(box_name) + 1 : -1]
  
                  self._insert(
                      box=box_name,
                      text_or_url=url,
                      left=specs[0],
                      top=specs[1],
                      height=specs[2],
                      width=specs[3],
                      slide=slide_num,
                  )
  
      if not imgStretch:
          for s, slide in enumerate(self["presentation"]["slides"]):
              for c, child in enumerate(slide["children"]):
                  if child["type"] in ["Image", "Plotly"]:
                      deep_child = child["props"]["style"]
                      width = deep_child["width"]
                      height = deep_child["height"]
  
                      if width >= height:
                          deep_child["max-width"] = deep_child.pop(
                              "width"
                          )
                      else:
                          deep_child["max-height"] = deep_child.pop(
                              "height"
                          )
  
imports: import copy
  import random
  import re
  import string
  import warnings
  import _plotly_utils.exceptions
  from chart_studio import exceptions
  from chart_studio.config import get_config
label_desc: Use image node_id 2 for calling the Presentation obj's underlying member method code with example usage: obj._markdown_to_presentation(markdown_string, style, imgStretch) without return types