code: def get_single_page_blocks(
      doc,
      pnum: int,
      tess_lang: str,
      spellchecker: Optional[SpellChecker] = None,
      ocr=False,
  ) -> Tuple[List[Block], int]:
      page = doc[pnum]
      rotation = page.rotation
  
      if ocr:
          blocks = ocr_entire_page(page, tess_lang, spellchecker)
      else:
          blocks = page.get_text(
              "dict", sort=True, flags=settings.TEXT_FLAGS
          )["blocks"]
  
      page_blocks = []
      span_id = 0
      for block_idx, block in enumerate(blocks):
          block_lines = []
          for l in block["lines"]:
              spans = []
              for i, s in enumerate(l["spans"]):
                  block_text = s["text"]
                  bbox = s["bbox"]
                  span_obj = Span(
                      text=block_text,
                      bbox=correct_rotation(bbox, page),
                      span_id=f"{pnum}_{span_id}",
                      font=f"{s['font']}_{font_flags_decomposer(s['flags'])}",  # Add font flags to end of font
                      color=s["color"],
                      ascender=s["ascender"],
                      descender=s["descender"],
                  )
                  spans.append(span_obj)  # Text, bounding box, span id
                  span_id += 1
              line_obj = Line(
                  spans=spans,
                  bbox=correct_rotation(l["bbox"], page),
              )
              # Only select valid lines, with positive bboxes
              if line_obj.area > 0:
                  block_lines.append(line_obj)
          block_obj = Block(
              lines=block_lines,
              bbox=correct_rotation(block["bbox"], page),
              pnum=pnum,
          )
          # Only select blocks with multiple lines
          if len(block_lines) > 0:
              page_blocks.append(block_obj)
  
      # If the page was rotated, sort the text again
      if rotation > 0:
          page_blocks = sort_rotated_text(page_blocks)
      return page_blocks
  
file_path: pdf-to-markdown/marker/extract_text.py
imports: import os
  from typing import Tuple, List, Optional
  from spellchecker import SpellChecker
  from marker.bbox import correct_rotation
  from marker.ocr.page import ocr_entire_page
  from marker.ocr.utils import detect_bad_ocr, font_flags_decomposer
  from marker.settings import settings
  from marker.schema import Span, Line, Block, Page
  from concurrent.futures import ThreadPoolExecutor
label_desc: Use image node_id 2 for calling a global function with example usage: get_single_page_blocks(doc, pnum, tess_lang, spellchecker, ocr) and returns: page_blocks